In the oAuth V1 we used to be able to query the system using the userid..something like:
https://api.fitbit.com/1/user/<fitBitUserID>/activity/date/<someDate>.json
After I register a user using oAuth v2, I am not longer able to query the user using this method, is this supported?
Thanks,
Luke
Answered! Go to the Best Answer.
I think I have this figured out. The documentation on the activities seems to indicate that you can query the user directly without have to specify the Bearer in the header by just putting the userid into the query string. This does not appear to be the case. I included the bearer with the accesstoken and that appears to have solved the issue.
Best Answer
Community Moderator Alumni are previous members of the Moderation Team, which ensures conversations are friendly, factual, and on-topic. Moderators are here to answer questions, escalate bugs, and make sure your voice is heard by the larger Fitbit team. Learn more
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.
@AndrewFitbit It was a new registration under oAuth V2. The error message is:
{"errors":[{"errorType":"insufficient_scope","message":"This application does not have permission to access activity data. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."}],"success":false}
I specified all of the available scopes.
Luke
Best Answer
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.
Did the person actually grant your app the scopes requested? The scopes the person authorized are returned with the access token.
Best AnswerI was using my test account. Also, I am trying to send you an email from my office email in a response from fitbit-support but am getting a 5.7.50.
Best AnswerI think I have this figured out. The documentation on the activities seems to indicate that you can query the user directly without have to specify the Bearer in the header by just putting the userid into the query string. This does not appear to be the case. I included the bearer with the accesstoken and that appears to have solved the issue.
Best Answer
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.
Correct, you must include the Authorization header. This is part of OAuth 2.0. If you don't include the Authorization header, the Fitbit Web API has no way of knowing what app is making the request and what person has authorized the app.
Looking at the error message returned will help diagnose issues. For example, if you do a GET request on https://api.fitbit.com/1/user/-/activities/date/2016-08-04.json , you'll get this error:
HTTP/1.1 401 Unauthorized
{
"errors": [
{
"errorType": "invalid_request",
"message": "Authorization header required. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."
}
],
"success": false
}
Best AnswerI was hoping that base64'ing the clientid and my secret and then using the userid in the query string that I would avoid having to build logic for refreshing the users auth token.
Best Answer
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.
Your client id and secret only identify your app to the API. This can be used in some requests that are "client only" requests, where the API only needs to know what app is making the request.
When your app makes requests on behalf of a person, you must use the access token. The access token represents the specific user authorization and the scope level they approved.
Best Answer
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.
You got it! 👍
Best Answer