Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tolgee sync does not use the tolgee login credentials #138

Open
jessielaf opened this issue Dec 14, 2024 · 4 comments
Open

Tolgee sync does not use the tolgee login credentials #138

jessielaf opened this issue Dec 14, 2024 · 4 comments
Assignees

Comments

@jessielaf
Copy link

Environment

Tolgee CLI Version: 2.4.1 (installed via npm)
Dockerized Tolgee Version: latest
Node Version: 22.9
Operating System: Mac m2

Issue

I am using local tolgee in docker. I have installed the cli through npm. After I run the login command:

$: tolgee login tgpak_... --api-url http://localhost:8080

I successfully login. However, if I then try to do a sync I get the following error:

$: tolgee sync       
🔴 No API key has been provided. You must either provide one via --api-key, or login via `tolgee login`.

Even if though I just logged in using the cli. Then another weird issue occurs. The generated api key is for a specific project but when I run the sync command with the manual settings I get the following error:

$ tolgee sync --api-key tgpak_gfptkoltojwtg4lmgu3dc43uobwhcyljgb2wqyjvmfywu --api-url http://localhost:8080
🐭✅     Analyzing code...
Sync complete!

My .tolgeerc looks like this:

{
  "$schema": "http://localhost:8080/cli-schema.json",
  "format": "JSON_TOLGEE",
  "patterns": ["./src/**/*.ts?(x)", "./src/**/*.svelte?(x)"],
  "push": {
    "files": [{
      "path": "./public/i18n/en.json",
      "language": "en"
    }],
    "forceMode": "OVERRIDE"
  },
  "pull": {
    "path": "./public/i18n"
  }
}

Is this a bug or did I configure something wrong?

@stepan662
Copy link
Contributor

stepan662 commented Dec 16, 2024

Hey, I think it's not a bug but the fact that the CLI allows you to login to multiple projects at once, so you'd need to provide the projectId property for it to select the correct api key.

I plan to look into this because it's not very user friendly.

@JanCizmar
Copy link
Contributor

Maybe we may require the projectId in the config. The config should be same for all project users so it dosn't make much sense that it works for one but doesn't for another, who has multiple api keys stored for login.

@jessielaf
Copy link
Author

@stepan662 I logged in using an API key from a specific project, but I can imagine it does not automatically detect this.

@JanCizmar There was a projectId in the config.

@stepan662
Copy link
Contributor

If you specify projectId in the config it should work, I've tested this and it works.

The issue is that if you just login with PAK, it will parse out projectId and store the key for that given projectId. Then when you try to do anything without specifying the projectId it doesn't know that it should use that stored PAK, because it's stored globally. So basically you have to always specify either projectId or the PAK (via the --api-key argument).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants