Sha256: 40eba7d793613f29c46a15f047e43c8090d6bc28c58fdc2377bb476e93a7f17c
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
module OAuth2Client module Grant # Authorization Code Grant # @see http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1 class AuthorizationCode < Base def response_type "code" end def grant_type "authorization_code" end # Authorization Request # @see http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1.1 def authorization_path(params={}) params = params.merge(authorization_params) "#{@authorize_path}?#{to_query(params)}" end def authorization_url(params={}) params = params.merge(authorization_params) build_url(host, :path => authorize_path, :params => params) end # Access Token Request # @see http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1.3 def token_path(params={}) unless params.empty? return "#{@token_path}?#{to_query(params)}" end @token_path end # Retrieve page at authorization path # # @param [Hash] opts options def fetch_authorization_url(opts={}) opts[:params] = opts.fetch(:params, {}).merge(authorization_params) method = opts.delete(:method) || :get make_request(method, @authorize_path, opts) end # Retrieve an access token for a given auth code # # @param [String] code refresh token # @param [Hash] params additional params # @param [Hash] opts options def get_token(code, opts={}) opts[:params] = { :grant_type => grant_type, :code => code }.merge(opts.fetch(:params, {})) opts[:authenticate] ||= :headers method = opts.delete(:method) || :post make_request(method, token_path, opts) end # Default authorization request parameters def authorization_params { :response_type => response_type, :client_id => @client_id } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oauth2-client-2.0.0 | lib/oauth2-client/grant/authorization_code.rb |