07-16-2015 17:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-16-2015 17:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi,
I am getting a 401 Unauthorized access response when trying to submit a POST request to /1/user/-/foods/log.json
I have verified my request oauth_signature at http://nouncer.com/oauth/authentication.html which matches with the signature my code produces.
Below is what my request looks like, will appreciate pointers into why it is not going through correctly.
POST https://api.fitbit.com/1/user/-/foods/log.json HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth oauth_consumer_key="foo-bar", oauth_nonce="0bpar0d9xjar6vwe", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1437092999", oauth_token="foo-bar", oauth_version="1.0", oauth_signature="sig-bar"
Host: api.fitbit.com
Content-Length: 67
Expect: 100-continue
foodId=14662809&mealTypeId=1&unitId=259&amount=1.00&date=2015-07-16
Answered! Go to the Best Answer.

- Labels:
-
.NET
-
OAuth 1.0a
-
Subscriptions API
Accepted Solutions
07-16-2015 18:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



07-16-2015 18:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
This error means that your application does not have write permissions. You'll need to change this in your application settings at https://dev.fitbit.com/apps/ . Note: this will immediately invalidate all previously granted user access tokens.

07-16-2015 17:55
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



07-16-2015 17:55
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Please validate your base string and signature using our OAuth 1.0a debug tool or use OAuth 2.0.

07-16-2015 17:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-16-2015 17:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The tool https://dev.fitbit.com/apps/oauthtutorialpage does not support supplying parameters for POST request.

07-16-2015 18:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-16-2015 18:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Also, i can confirm that the with no parameters the OAuth signature on https://dev.fitbit.com/apps/oauthtutorialpage and my code is same. But hitting the get food api still returns 401 error.

07-16-2015 18:18
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



07-16-2015 18:18
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
With the OAuth 1.0a signature, it doesn't matter if the parameters are URL or body parameters. To test, put your body parameters as URL parameters and compare the base strings and signature.

07-16-2015 18:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-16-2015 18:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I have an exact signature match between signature generated by my code and https://dev.fitbit.com/apps/oauthtutorialpage with parameters being added to request url.
And still the response if error 401.

07-16-2015 18:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-16-2015 18:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Copying the error message:
{"errors":[{"errorType":"request","fieldName":"n/a","message":"Read-only API client is not authorized to update resources"}],"success":false}
what does "Read-only API client" mean?

07-16-2015 18:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



07-16-2015 18:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
This error means that your application does not have write permissions. You'll need to change this in your application settings at https://dev.fitbit.com/apps/ . Note: this will immediately invalidate all previously granted user access tokens.

