Access github API with rails oauth plugin -
i'm implementing application supposed able talk different apis on behalf of users. amongst others, includes github. i'm using oauth-plugin (https://github.com/pelle/oauth-plugin) perform authentication each api. unfortunately, doesn't work github.
here's current githubtoken implementation:
class githubtoken < consumertoken github_settings={ :site=>"https://github.com", :request_token_path => "/login/oauth/request_token", :authorize_path => "/login/oauth/authorize", :access_token_path => "/login/oauth/access_token", } def self.consumer @consumer||=create_consumer end def self.create_consumer(options={}) oauth::consumer.new credentials[:key],credentials[:secret],github_settings.merge(options) end def self.get_request_token(callback_url, scope=nil) https://github.com/login/oauth/authorize consumer.get_request_token({:oauth_callback=>callback_url}, :scope=>scope||credentials[:scope]||"") end end
when starting authentication process, 403 error during get_request_token call. assume request_token_path somehow wrong, unable find information on correct path. searching google github part of search term not helpful. try omniauth now, i'm planning on using provider capabilities of oauth-plugin, well, appreciated.
ok, solved it. following configuration in initialisers/oauth_consumers.rb trick:
oauth_credentials={ :github=>{ :key => "key", :secret => "secret", :expose => false, # expose client @ /oauth_consumers/twitter/client see docs :oauth_version => 2, :options => { :site => 'https://github.com', :authorize_url => '/login/oauth/authorize', :token_url => '/login/oauth/access_token' } } }
also make sure register /oauth_consumers/github/callback2 callback url.
Comments
Post a Comment