Skip to content

OAuth::Unauthorized (401 Unauthorized) #81

@billym

Description

@billym

Hi. Since we upgraded to rail 3.2 our 3-legged authorization to twitter (https://dev.twitter.com/docs/auth/3-legged-authorization) has stopped working and we get the following error:

OAuth::Unauthorized (401 Unauthorized):
oauth (0.4.7) lib/oauth/consumer.rb:216:in token_request' oauth (0.4.7) lib/oauth/tokens/request_token.rb:18:inget_access_token'
app/controllers/twitter_controller.rb:40:in `callback'

Nothing was changed in the code, or keys.
I have googled and tried several solutions from others who have had similar 401 problems but nothing works:
-the server time is correct on all servers tested.
-The callback url is set in the Twitter (My applications) area, even tho oauth 1.0a doesn't require it as it is passed in our call to twitter:

options = {
:site => "https://api.twitter.com",
:scheme => :header
}
consumer = OAuth::Consumer.new(token, secret, options)
request_token = consumer.get_request_token(:oauth_callback => callback_url)
session[:request_token] = request_token

On the callback to our app is where the problem occurs when we try to get_access_token:

def callback
request_token = session[:request_token]
access_token = request_token.get_access_token
...
end

We are on Ruby 1.9.3-p327, rails 3.2.10. Any help would be appreciated. Let me know if more debugging output is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions