Hi!
I'm trying to create a subscriber with the following request:
Body:
{
"endpointUri": "MY_WEBHOOK_URL",
"subscriberConfigs": [
{
"dataTypes": ["steps", "weight"],
"subscriptionCreatePolicy": "AUTOMATIC"
}
],
"endpointAuthorization": {
"secret": "Bearer XXX"
}
}
Response:
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
When testing my access token (https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=XXX) I have the correct scopes:
"scope": "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/googlehealth.activity_and_fitness.readonly https://www.googleapis.com/auth/googlehealth.health_metrics_and_measurements.readonly",
This endpoit is suppose to require the https://www.googleapis.com/auth/cloud-platform scope that I have, my user is also owner of the project.
Is this a bug or what am I doing wrong?
best regards
Alexander
Answered! Go to the Best Answer.
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.
Hi @shapelink
Thank you for your patience. In the create subscriber endpoint, you need to use the project id instead of the project name in the URL. For example, here is the syntax I used to create a subscriber.
POST {{google_health_v4_host}}/projects/6183080339/subscribers?subscriberId=webhooks
Authorization: Bearer {{access_token}}
Accept: application/json
{
"endpointUri": "<endpoint-URL>",
"subscriberConfigs": [
{
"dataTypes": [
"steps", "weight", "sleep"
],
"subscriptionCreatePolicy": "AUTOMATIC"
}
],
"endpointAuthorization" : {
"secret": "Bearer 618308034039-au5r1vjbnic6pp.apps.googleusercontent.com"
}
}
I'm working on some instructions to put in the documentation to help with creating a subscriber. Let me know what happens after changing the project name to project id.
No, I have not been able to create a subscriber. I have tested with acess tokens created from both oauth flow and service account.
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.
Hi @shapelink
Welcome to the community.
We are currently investigating the issue. I will share more details once I have any updates. Thanks!
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.
Hi @shapelink
Thank you for your patience. In the create subscriber endpoint, you need to use the project id instead of the project name in the URL. For example, here is the syntax I used to create a subscriber.
POST {{google_health_v4_host}}/projects/6183080339/subscribers?subscriberId=webhooks
Authorization: Bearer {{access_token}}
Accept: application/json
{
"endpointUri": "<endpoint-URL>",
"subscriberConfigs": [
{
"dataTypes": [
"steps", "weight", "sleep"
],
"subscriptionCreatePolicy": "AUTOMATIC"
}
],
"endpointAuthorization" : {
"secret": "Bearer 618308034039-au5r1vjbnic6pp.apps.googleusercontent.com"
}
}
I'm working on some instructions to put in the documentation to help with creating a subscriber. Let me know what happens after changing the project name to project id.
Replacing the project ID with the project NUMBER worked! It would probably be good to update the documentation and specify that it is the project number that should be used.
Thanks!