03-10-2018 00:43 - edited 03-10-2018 02:54
03-10-2018 00:43 - edited 03-10-2018 02:54
I confirm oauth2 by url:
https://www.fitbit.com/oauth2/authorize?response_type=code&prompt=consent&client_id=22CNHL&redirect_uri=myapp%3A%2F%2localhost&scope=activity
I had get code from url callback:
code = intent.data.getQueryParameter("code") // value of code ="040499f5bff449...d9f04c7a0da58ecb3"
I using this url get token:
var url = "https://api.fitbit.com/oauth2/token
Result I have 2 value:
accesstoken=json.getString("access_token")
refesh_token=json.getString("refresh_token")
I refresh token by url:
var url = "https://api.fitbit.com/oauth2/token?grant_type=refresh_token&refresh_token=" + refesh_token
Result I have a user_id:
user_id=json.getString("user_id")
I use user_id to access data by url:
var url="https://api.fitbit.com/1/user/"+user_id+"/activities/date/2018-03-10.json"
But it occur error:
{"errors":[{"errorType":"system","fieldName":"n/a","message":"Authorization Error: Invalid authorization token type"}],"success":false}
Why? What is token type?
Thank you.
Answered! Go to the Best Answer.
04-10-2018 02:51
04-10-2018 02:51
the cause: i not set access token to header.
04-10-2018 02:51
04-10-2018 02:51
the cause: i not set access token to header.