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

VATSIM_CORE_API_TOKEN Env Variable not being properly read. #1081

Closed
hatoriganzo opened this issue Dec 7, 2024 · 18 comments
Closed

VATSIM_CORE_API_TOKEN Env Variable not being properly read. #1081

hatoriganzo opened this issue Dec 7, 2024 · 18 comments
Labels
bug Something isn't working triage

Comments

@hatoriganzo
Copy link
Contributor

hatoriganzo commented Dec 7, 2024

Environment
CC Version: ghcr.io/vatsim-scandinavia/control-center:v4
Host type: Docker Compose running on Portainer

Describe the bug
VATSIM API V2 token is not being read when configured per documentation as the VATSIM_CORE_API_TOKEN environment variable in the dockercompose.yml.

How to reproduce
Steps to reproduce the behavior:

  1. Set VATSIM_CORE_API_TOKEN to a valid (Tested via Postman) API Core V2 Token.
  2. Navigate to /users
  3. Get Error fetching users from VATSIM API. Check if your token is correct error message.

Expected behavior
Working user page

Screenshots
image

Additional context
After some tracking, I noted the config variable is being assigned in config/vatsim.php line 15.

'core_api_token' => env('VATSIM_CORE_API_TOKEN', null),

Running php artisan tinker in the container I noticed the ENV variable is properly set but the config property stays null. Works with other variables assigned the same way tho.
image

@hatoriganzo hatoriganzo added bug Something isn't working triage labels Dec 7, 2024
@blt950
Copy link
Member

blt950 commented Dec 7, 2024

Sorry, but I can't give you support on almost year old version (v4) when v6 is now the current one. Please update to v6 and let me know if the issue still persists.

@hatoriganzo
Copy link
Contributor Author

Oh! (Might want to update the docs :P) Updating.

And yeah, the variable name changed that's why.

@blt950
Copy link
Member

blt950 commented Dec 7, 2024

Can you link me to the docs where it told you to download to v4? I'll correct it

@hatoriganzo
Copy link
Contributor Author

Sure! It's on the following pages:

https://docs.vatsca.org/controlcenter/latest/getting-started/
In the example docker-compose.yml

https://docs.vatsca.org/controlcenter/latest/installation/
Open up a terminal and pull the latest image with:
docker pull ghcr.io/vatsim-scandinavia/control-center:v4

@hatoriganzo
Copy link
Contributor Author

image

Unfortunately, I'm still having issues with my API Key (Updated to V6.06). Although now the config is getting set correctly.

image

@hatoriganzo hatoriganzo reopened this Dec 7, 2024
@bedrich-schindler
Copy link
Contributor

bedrich-schindler commented Dec 7, 2024

If VATSIM_CORE_API_TOKEN is correctly set in .env file, try to call php artisan key:generate. This helps me when changing something in the config ...

Also try to call php artisan optimize:clear just to be sure that cache is cleared.

Call all the commands inside the container.

@hatoriganzo
Copy link
Contributor Author

Ran both commands inside the container but the issue remains.

@blt950
Copy link
Member

blt950 commented Dec 7, 2024

I don't understand why this wouldn't work for you unless the key is actually invalid or maybe an v1 key. Everything works on my end here.

Confirm this key of yours can be called in the https://api.vatsim.net/v2/ API successfully?

@bedrich-schindler
Copy link
Contributor

I personally do not use Docker on production, but what about this? https://docs.vatsca.org/controlcenter/latest/getting-started/#add-the-docker-compose-file. Environment is specified in docker-compose file in this example. I do not know how @hatoriganzo configured CC, but can't be this problem? You can also specify .env file using https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables/#use-the-env_file-attribute

But I am just guessing and throwing some stuff that came up to my mind

@bedrich-schindler
Copy link
Contributor

Also, @hatoriganzo, did you check that you have latest image? From my experience, sometimes I must explicitly rebuild the image otherwise old tag is installed (v4 instead v6). Something like docker compose --build --no-cache ...

@blt950
Copy link
Member

blt950 commented Dec 7, 2024

Since @hatoriganzo already did tinker and vatsim.core_api_token and got back his key, I'd assume the key itself is available.
For checking the version, look at the bottom left in sidebar.

@hatoriganzo
Copy link
Contributor Author

Yeah I'm starting to think the key is the issue. It was just given to me from the dev team but I'll inquiry with them. Do you know any endpoint in the API that REQUIRES the key so I can properly test?

@blt950
Copy link
Member

blt950 commented Dec 7, 2024

@hatoriganzo
Copy link
Contributor Author

Yeah, it's working :c

image

@hatoriganzo
Copy link
Contributor Author

Since @hatoriganzo already did tinker and vatsim.core_api_token and got back his key, I'd assume the key itself is available. For checking the version, look at the bottom left in sidebar.

image

Confirmed 6.0.6

@blt950
Copy link
Member

blt950 commented Dec 7, 2024

I found out why.. Because the API calls the subdivision call instead of division😅😅

$url = sprintf('https://api.vatsim.net/v2/orgs/subdivision/%s', config('app.owner_code'));

If you change this to the division call instead?

@hatoriganzo
Copy link
Contributor Author

Changed the code and. 🥁

It worked

@hatoriganzo
Copy link
Contributor Author

Marking as closed as related to #1080.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

3 participants