Skip to content

OAuth2::Error in callback2 when trying to connect consumer to facebook #148

@jdejong

Description

@jdejong

Using rails 4 and the following gems:
oauth (0.4.7)
oauth-plugin (0.5.1)
oauth2 (0.9.4)

I changed the OauthConsumersController class to have the following to get the exception.

def callback2
    begin
      super
    rescue Exception => e 
      puts e.response.inspect
      puts e.code.inspect
      puts e.description.inspect
    end
end

and the value of e.response is:

#<OAuth2::Response:0x007fea70c65ae0 @response=#<Faraday::Response:0x007fea70c5ec68 @on_complete_callbacks=[], @env=#<Faraday::Env @method=:post @body="access_token=token_removed_for_security_reasons&expires=5145879" @url=#<URI::HTTPS:0x007fea70fbe660 URL:https://graph.facebook.com/oauth/access_token> @request=#<Faraday::RequestOptions (empty)> @request_headers={"User-Agent"=>"Faraday v0.9.0", "Content-Type"=>"application/x-www-form-urlencoded"} @ssl=#<Faraday::SSLOptions verify=true> @response_headers={"content-type"=>"text/plain; charset=UTF-8", "pragma"=>"no-cache", "access-control-allow-origin"=>"*", "x-fb-rev"=>"1306262", "cache-control"=>"private, no-cache, no-store, must-revalidate", "expires"=>"Sat, 01 Jan 2000 00:00:00 GMT", "x-fb-debug"=>"BaE/kxwDArTbj7L/f6QFrklMuuOnUsoIPt0N1LpMbs+4+V4tP+QkkupCzZhMyUYmo1mhfpVimzzJ1+dQ1cxVrg==", "date"=>"Thu, 26 Jun 2014 12:25:54 GMT", "connection"=>"close", "content-length"=>"211"} @status=200>>, @options={:parse=>nil}, @error=#<OAuth2::Error: access_token=token_removed_for_security_reasons&expires=5145879>, @parsed="access_token=token_removed_for_security_reasons&expires=5145879">

and my oauth_consumers.rb is:

OAUTH_CREDENTIALS={
   :facebook=>{
     :key => APP_CONFIG['facebook_consumer_key'],
     :secret => APP_CONFIG['facebook_consumer_secret'],
     :oauth_version => 2,
     :super_class => 'Oauth2Token',
     :scope => 'offline_access,publish_stream',
     :options => {
       :site => 'https://graph.facebook.com',
       :scope => 'offline_access,publish_stream',
       :token_url => '/oauth/access_token',
       :redirect_uri => 'http://0.0.0.0:3000/oauth_consumers/facebook/callback2'
     } 
   }
}

OAUTH_CREDENTIALS={
} unless defined? OAUTH_CREDENTIALS

load 'oauth/models/consumers/service_loader.rb'

i added the token_url and redirect_url because of errors I received from the gem and facebook.

Any ideas why this is happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions