01-18-2025 20:26
01-18-2025 20:26
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
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
01-21-2025 10:03
Hi @badcb
I have a few questions for you:
Best Answer01-22-2025 21:07
01-22-2025 21:07
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'
},
Best Answer01-23-2025 08:11
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
01-23-2025 08:11
Did you provide the body parameters in your https://api.fitbit.com/oauth2/token endpoint call?
Best Answer01-23-2025 20:34
01-23-2025 20:34
Yes, I do that immediately below the code I pasted above:
form: {
code: code,
grant_type: 'authorization_code',
redirect_uri: redirectUri,
code_verifier: codeVerifier
}
Best Answer01-24-2025 06:27
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
01-24-2025 06:27
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?
Best Answer01-24-2025 08:53
01-24-2025 08:53
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
Best Answer01-24-2025 09:56
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
01-24-2025 09:56
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.
Best Answer