Invalid JWT header

I'm trying to call GetAssistanceData (https://api.nrfcloud.com/v1/location/agps)
But the response is:
{
"message": "Invalid JWT header: \"alg\" field must be set to valid signing algorithm.",
"code": 40003
}

I have generated my JWT in Manage Service Key section, and have passed it to my header as described in the docs:

let options = new URL('api.nrfcloud.com/.../agps');
options.method = 'GET';
options.headers = {
'Content-Type': 'application/octet-stream',
'Authorization': `Bearer ${NRF_CLOUD_API_KEY}`,
'Range': 'bytes=0-2200'
};

Any thoughts on why the JWT header would be invalid?

Parents
  • That error message indicates that the JWT could not be decoded in some way (not necessarily a problem with the signing algorithm field).

    Your variable NRF_CLOUD_API_KEY implies you are using your API key, which is found in the nrfcloud.com portal under the User Account page. This is different from a JWT, such as the one generated for you from the Manage Service Key page. Are you sure you're passing the JWT?

    Check your HTTP traffic to verify that the Bearer token contains the same string as the JWT from the Manage Service Key page. Also look for things such as leading/trailing extra characters / newlines etc.

Reply
  • That error message indicates that the JWT could not be decoded in some way (not necessarily a problem with the signing algorithm field).

    Your variable NRF_CLOUD_API_KEY implies you are using your API key, which is found in the nrfcloud.com portal under the User Account page. This is different from a JWT, such as the one generated for you from the Manage Service Key page. Are you sure you're passing the JWT?

    Check your HTTP traffic to verify that the Bearer token contains the same string as the JWT from the Manage Service Key page. Also look for things such as leading/trailing extra characters / newlines etc.

Children
No Data
Related