0

I'm trying to use the oauth-ruby gem (https://github.com/oauth-xx/oauth-ruby/) in my Rails application to let users authenticate with a 3rd party API, but I'm having problems getting the oauth_callback to work properly when using get_request_token. Here is the code that keeps failing:

@request_token = oauth_consumer.get_request_token(:oauth_callback => "http://myurl.com")

This results in a 400 Bad Request "OAuth::Unauthorized" error everytime. However when I remove that from my code it returns a request token fine:

@request_token = oauth_consumer.get_request_token()

The problem I'm facing is that when doing this I am not able to be redirected back to my application once the user has authenticated with the 3rd party. Is this an issue with my code or something to do with how the 3rd party handles oauth_callbacks?

Thanks, Chris

Halfwarr
  • 7,853
  • 6
  • 33
  • 51
cmahon
  • 1
  • 2

1 Answers1

0

That error probably become because the API you requested needs you to save at least one callback URL. Review the API and add your test/production callback url from your dashboard, then the API could validate it on every request you do.

  • Thanks for the reply, the issue is that the API provider hasn't given me a way of telling them what I want the callback URL to be. I'm assuming this means the issue on the 3rd party providers end and not mine? – cmahon Aug 21 '15 at 16:04
  • Yes it is a provider problem or at least, not an issue in the manner you're implementing the gem. Maybe they have an specific url to do the callback or an implementation via javascript that could be more useful. – Wenceslao Negrete Aug 23 '15 at 06:36
  • Thanks, good to know it isn't me going crazy thinking I was doing something wrong :) – cmahon Aug 24 '15 at 07:42