Not authorised error message for valid user

Hi,
I have two issues:
We created an Org and an associated user using the admin API.
After creating the user i was able to curl the APIs /api/users & api/apis. using the authorization key for the user. All worked fine last night.
Now this morning when i execute same curl request from last night it now fails with:
{“Status”:“Error”,“Message”:“Not authorised”,“Meta”:null}
I am able to login on the dashboard and see the APIs and Users for the Org. The API credential of the user is still exactly the same as the one obtained during user creation. Is this a known behaviour?

Second Question is about the API URL shown on the dashboard.
Under “Registered API Configuration” when i click edit, the API URL shown is not correct.
it shows: http://www.mydomain.com/my_api_name
But it should be: https://api.mydomain.com/my_api_name
In the tyk_analytics.conf i have:
“host_config”: {
“enable_host_names”: false,
“disable_org_slug_prefix”: true,
“hostname”: "“https://dashboard.mydomain.com”,
“override_hostname”: “https://api.mydomain.com”,
“portal_domains”: {},
“portal_root_path”: “/portal”
},

Which part of the config do i have to update to get the correct API URL displayed?

Hi Del,

Regarding the error message, have you restarted Redis ?
Is this your exact host_config ? It’s not a valid JSON (notice the double quotes in hostname), therefore your Dashboard won’t run.

Thanks,
Kos @ Tyk Support Team

No i didnt restarted redis.
Just a while ago i logged onto the dashboard, under edit user i selected “Account is admin” then pressed update. After doing that i was able to curl /api/users/ and /api/apis/ just like before.
Then i went in again and unchecked “Account is admin” for the user then pressed update and tested it and it still working. Not so sure what happened there but giving the user admin permission and then removing it seems to resolve the issue (perhaps this triggered the redis restart?). I wouldnt expect to have to do a redis restart after adding new users…

Regarding the host_config sorry that is my mistake as i tried to anonymise the config.
I have played around with the hostconfig settings now i get the following API URL on the dashboard:
http://https://api.mydomain.com/my_api_name
It seems the dashboard by default prefixes the API URL with “http” regardless whether https is enabled and in use.

“host_config”: {
“enable_host_names”: false,
“disable_org_slug_prefix”: true,
“hostname”: “https://dashboard.mydomain.com”,
“override_hostname”: “https://api.mydomain.com”,
“portal_domains”: {},
“portal_root_path”: “/portal”
},

Hi Del,

Tyk definitely doesn’t restart Redis.
Good to hear that it works now, let us know if you experience this issue again.

Thanks.
Kos @ Tyk Support Team

Can you give some pointers on the second question i.e. why the API URL is prefixed with “http” ?

You don’t need the http(s) part here, it’s probably what is causing the issue in your portal.

Thanks for your response. I have tried it earlier without https, I modied the conf file and restarted.
the settings are currently without the “https://” prefix for both lines. But on the dashboard the API URL is currently: http://api.mydomain.com/my_api_name.

Current setting:
“hostname”: “dashboard.mydomain.com”,
“override_hostname”: “api.mydomain.com”,

You need to set:

host_config.generate_secure_paths: As of v2.1, Tyk Dashboard tries to generate URLs for you that can be used straight from the Dashboard, if you prefer to have the URLs start with https, set this option to true. This is a purely aesthetic change.

Thanks Martin that solved it!