01-18-2025 20:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-18-2025 20:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi!
I keep getting a console error for invalid_grant. It says my authorization code is invalid, but it isn't expiring and it seems to be a valid code. Can you please help?
01-21-2025 10:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-21-2025 10:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi @badcb
I have a few questions for you:
- At https://dev.fitbit.com/apps, what is the application type for your client ID?
- Please provide your complete authorization URL so I can test your consent flow
- What syntax are you using to convert the authorization code to an access token and refresh token. Please redact the authorization code and code_verifier values.
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

01-22-2025 21:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-22-2025 21:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thanks for getting back to me!
application type: Browser
authorization URL: 'https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=${clientId}&redirect_uri=${enco...
syntax to convert authorization code to access token:
onst authOptions = {
url: 'https://api.fitbit.com/oauth2/token',
method: 'POST',
headers: {
'Authorization': 'Basic ' + Buffer.from(clientId + ':' + clientSecret).toString('base64'),
'Content-Type': 'application/x-www-form-urlencoded'
},

01-23-2025 08:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-23-2025 08:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Did you provide the body parameters in your https://api.fitbit.com/oauth2/token endpoint call?
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

01-23-2025 20:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-23-2025 20:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yes, I do that immediately below the code I pasted above:
form: {
code: code,
grant_type: 'authorization_code',
redirect_uri: redirectUri,
code_verifier: codeVerifier
}

01-24-2025 06:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-24-2025 06:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
1. When you extract the authorization code from the redirect URL, are you getting the text as described in step 3 of this part of the documentation: https://dev.fitbit.com/build/reference/web-api/developer-guide/authorization/#Authorization-Code-Gra...
2. Have you verified that you are getting a new code for each authorization attempt, even for the same user?
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

01-24-2025 08:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-24-2025 08:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I am getting a new code everytime for each authorization attempt, but in the callback URL, my authorization codes are longer than the 21 character code shown in step #3 of https://dev.fitbit.com/build/reference/web-api/developer-guide/authorization/#Authorization-Code-Gra.... The codes in my URL's are 40 characters long

01-24-2025 09:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-24-2025 09:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The 40 character code you're getting is correct. We likely truncated the code to 21 characters since it is public documentation.
I'm going to email you directly to get some more information.
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

