class OAuth2::Strategy::AuthCode

The Authorization Code Strategy

@see tools.ietf.org/html/draft-ietf-oauth-v2-15#section-4.1

Public Instance Methods

authorize_params(params = {}) click to toggle source

The required query parameters for the authorize URL

@param [Hash] params additional query parameters

# File lib/oauth2/strategy/auth_code.rb, line 10
def authorize_params(params = {})
  params.merge('response_type' => 'code', 'client_id' => @client.id)
end
authorize_url(params = {}) click to toggle source

The authorization URL endpoint of the provider

@param [Hash] params additional query parameters for the URL

# File lib/oauth2/strategy/auth_code.rb, line 17
def authorize_url(params = {})
  @client.authorize_url(authorize_params.merge(params))
end
get_token(code, params = {}, opts = {}) click to toggle source

Retrieve an access token given the specified validation code.

@param [String] code The Authorization Code value @param [Hash] params additional params @param [Hash] opts options @note that you must also provide a :redirect_uri with most OAuth 2.0 providers

# File lib/oauth2/strategy/auth_code.rb, line 27
def get_token(code, params = {}, opts = {})
  params = {'grant_type' => 'authorization_code', 'code' => code}.merge(client_params).merge(params)
  @client.get_token(params, opts)
end