Sha256: bc7a38a6bfcefeb01900219512d343860686a05752f6d0613cfbaaa620d2af34
Contents?: true
Size: 1013 Bytes
Versions: 1
Compression:
Stored size: 1013 Bytes
Contents
require 'cgi' require 'uri' module OmniAuth module Strategies class OAuth2 include OmniAuth::Strategy def initialize(app, name, client_id, client_secret, options = {}) super(app, name) @options = options @client = ::OAuth2::Client.new(client_id, client_secret, options) end attr_accessor :client_id, :client_secret, :options def request_phase(options = {}) redirect @client.web_server.authorize_url({:redirect_uri => callback_url}.merge(options)) end def callback_phase verifier = request.params['code'] @access_token = @client.web_server.get_access_token(verifier, :redirect_uri => callback_url) super rescue ::OAuth2::HTTPError => e fail!(:invalid_credentials) end def auth_hash OmniAuth::Utils.deep_merge(super, { 'credentials' => { 'token' => @access_token.token } }) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.0.1 | lib/omniauth/strategies/oauth2.rb |