04-26-2021 22:44
04-26-2021 22:44
I am trying to integrate fitbit with servicenow but getting
HTTP Error 401 - Unauthorized
error while getting the OAuth token please let me what could be the issue here.
04-28-2021 08:40
04-28-2021 08:40
Hi @shugufta
Would you please provide the endpoint and headers that you're executing when getting the 401 error. Please do not include any sensitive data like auth codes, tokens, client ids, secrets, etc.
Best,
Gordon
04-29-2021 03:59
04-29-2021 03:59
Hi Gordon,
Once I click the "https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=clientID&redirect_uri=https://dev63919.service-now.com/oauth_redirect.do&scope=activity%20nutrition%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight" link, it gives below error.
Your OAuth redirect failed. Please check if the redirect URL setup in your OAuth configuration matches your ServiceNow instance URL.
Also the response_type=code is not getting generated.
Kindly suggest on how we can get the code.
Thanks & Regards,
Shugufta.
04-29-2021 10:49
04-29-2021 10:49
Hi @shugufta
Thank you. Try specifying your redirect URL as "https%3A%2F%2Fdev63919.service-now.com%2Foauth_redirect.do"
04-29-2021 11:08
04-29-2021 11:50
04-29-2021 11:50
In your code, please specify the redirect URL as https%3A%2F%2Fdev63919.service-now.com%2Foauth_redirect.do instead of https://dev63919.service-now.com/oauth_redirect.do
04-29-2021 12:11
04-29-2021 12:11
Even then I am redirected to same page. When I test getting below response
{"success":false,"errors":[{"errorType":"invalid_token","message":"Access token invalid: null. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}]}
04-29-2021 12:17
04-29-2021 12:17
My main issue is it is not generating the code and giving me the response as below. I have given response_type=code here
{"errors":[{"errorType":"invalid_request","message":"Missing parameters: code Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}
04-30-2021 08:04
04-30-2021 08:04
Hi @shugufta
It seems you have several errors here, and we should address them one at a time. I'm not sure if your first error not being resolved is resulting in the other errors being generated.
I believe the first problem is when executing https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=clientID&redirect_uri=https://d... you receive the error
Your OAuth redirect failed. Please check if the redirect URL setup in your OAuth configuration matches your ServiceNow instance URL.
I believe this is because your application need to specify the redirect URL as redirect URL as https%3A%2F%2Fdev63919.service-now.com%2Foauth_redirect.do instead ofhttps://dev63919.service-now.com/oauth_redirect.do. However, the redirect URL in the dev.fitbit.com application configuration needs to be https://dev63919.service-now.com/oauth_redirect.do.
Once the user redirects back to your application, the redirect URL will have an authorization code.
ex. https://www.exampleapp.com/callback?code=6ec38fd5d19a5a3f85a021f673e15ae04e9293#_=_
You need to swap out the code for the access token.
example
POST https://api.fitbit.com/oauth2/token
Authorization: Basic <basic_token>
clientId=<client_id>&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fwww.exampleapp.com%2Fcallback"
&code=6ec38fd5d19a5a3f85a021f673e15ae04e9293
The response should provide you with the access_token. The OAuth 2.0 Tutorial can walk you through this process using your application settings. See https://dev.fitbit.com/build/reference/web-api/troubleshooting-guide/debugging-tools/#oauth-2-0-tuto....
If you're doing these steps as I've described, please provide the URL and error message that you're receiving.