Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Authorization Error: Invalid authorization token type

ANSWERED

Hello Fitbit dev team, 

 

I'm having some issues creating a subscription after verifying my subscriber endpoint and authenticating a user via the implicit grant flow. 

 

Once the user is authenticated, the user's access token is used to call the create a subscription api. 

 

However, when calling this endpoint with my configurations I am receiving this error message: 'Authorization Error: Invalid authorization token type' .

 

Here is the code I used to call the POST request endpoint:

const headers: {
  "Authorization": `Bearer <accessCode>`,
  "X-Fitbit-Subscriber-Id": "1",
  "content-length": "32"
};

const url = https://api.fitbit.com/1/user/-/apiSubscriptions/test.json

axios.post(url, headers);

 

 

 

 

 

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @Gordon-C ,

 

yes that is correct - the accessCode is the access token created after oauth2 flow. 

 

Just to update you, I managed to successfully create a subscription!

 

The steps I took are:

1. Revoke the user's access token

2. Authenticate the user to retrieve the access token

3. Use the access token to create a subscription with an Authorization and X-Fitbit-Subscriber-Id header

 

 

 

 

 

 

 

 

View best answer in original post

Best Answer
4 REPLIES 4

Hi @esef 

 

Is there a reason for surrounding your authorization header value with single tick marks, while the other header values use double-quotes?

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @Gordon-C ,

 

the authorization header value uses template literals (i.e backticks) to embed expressions such as the access code. I changed the backticks to double-quotes but I"m still receiving the same error message. 

 

const config = {
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer " + accessCode,
    "X-Fitbit-Subscriber-Id": "1",
    "Content-Length": "32"
  }
};
Best Answer
0 Votes

@esef ... when you say accessCode, you mean the access token that is created after oauth2 flow is complete?

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer

Hi @Gordon-C ,

 

yes that is correct - the accessCode is the access token created after oauth2 flow. 

 

Just to update you, I managed to successfully create a subscription!

 

The steps I took are:

1. Revoke the user's access token

2. Authenticate the user to retrieve the access token

3. Use the access token to create a subscription with an Authorization and X-Fitbit-Subscriber-Id header

 

 

 

 

 

 

 

 

Best Answer