randomperson25
randomperson25

Reputation: 175

Withings API Status Code 2555

I'm trying to integrate Withings with a rails apps. I'm using an Omniauth provider someone wrote called omniauth-withings. I was able to configure the provider to allow me to visit /auth/withings which redirects to the Withings authorization page. After I allow access, the browser is redirected to the callback url /auth/withings/callback. I have this routed to a controller action that attempts to get the measurement data from Withings using the simplificator-withings gem.

Withings.consumer_secret = ENV['withings_app_key']
Withings.consumer_key = ENV['withings_app_secret']

auth_hash = request.env['omniauth.auth']
user_id = auth_hash.extra.raw_info.body.users.first.id

withings_user = User.authenticate(user_id, auth_hash.credentials.token, auth_hash.credentials.secret)
measurements = withings_user.measurement_groups(:device => Withings::SCALE)

The problem happens when I call User.authenticate(), I get this:

An unknown error occurred - Status code: 2555

Is there something I'm missing here?

Upvotes: 1

Views: 671

Answers (1)

Brad Pitcher
Brad Pitcher

Reputation: 1785

I was getting the same error with a django app. It turns out I was using the wrong token and secret. I was using the oauth_token and oauth_token_secret returned from step 1 of the authorization process, rather than the oauth_token and oauth_token_secret from step 3. Make sure you are using the values from step 3. The API documentation shows the same values returned from these calls, but they will be different. Hopefully this helps you too.

Upvotes: 2

Related Questions