Problem type:
https://docs.nordicfinancialnews.com/problems/auth-invalid401 when it cannot authenticate your request. Four things produce it:
- No
Authorizationheader on the request. - An
Authorizationheader that is not inBearer YOUR_API_KEYform. - A key that matches nothing on record.
- A key that matches but is no longer usable, because it was revoked, deactivated, or has passed its expiry date.
detail reads the same in all four cases, and nothing else in the response narrows it down. Work through the four causes yourself rather than expecting the response to name one.
Example response
WWW-Authenticate header accompanies this response. A client that waits for an authentication challenge before attaching credentials will wait forever, so send the Authorization header on the first request.
How to fix it
Retrying will not help. Nothing about this condition changes on its own, so fix the request or the key before calling again.- Confirm the header is spelled
Authorizationand its value starts withBearerfollowed by a space, then the key. - Confirm you are sending the key itself rather than its name or ID.
- Check the key is still listed and active in API key settings. A revoked or expired key fails exactly like a wrong one.
401 while another returns 200 for the same key, the problem is not the key. Look at how that request is built instead.
Not the same as a 403
A401 means the API does not know who you are. A 403 means it does, and is refusing anyway: either your key lacks the scope the endpoint requires, which is insufficient permissions, or your plan does not reach the resource, which is plan limit exceeded. Adding a valid key fixes a 401 and never fixes a 403.
Related
- Authentication for how keys, scopes and headers work
- Error handling for the full problem type list