Class: Oauthio::Strategy::AuthCode

Inherits:
OAuth2::Strategy::AuthCode
  • Object
show all
Defined in:
lib/oauthio/strategy/auth_code.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ AuthCode



4
5
6
# File 'lib/oauthio/strategy/auth_code.rb', line 4

def initialize(client)
  @client = client
end

Instance Method Details

#authorize_params(params = {}) ⇒ Object

The required query parameters for the authorize URL



18
19
20
# File 'lib/oauthio/strategy/auth_code.rb', line 18

def authorize_params(params={})
  params.merge('k' => @client.id)
end

#authorize_url(provider, params = {}) ⇒ Object

The authorization URL endpoint of the provider



11
12
13
# File 'lib/oauthio/strategy/auth_code.rb', line 11

def authorize_url(provider, params = {})
  @client.authorize_url(provider, authorize_params.merge(params))
end

#client_paramsHash

The OAuth client_id and client_secret



25
26
27
# File 'lib/oauthio/strategy/auth_code.rb', line 25

def client_params
  {'key' => @client.id, 'secret' => @client.secret}
end

#get_token(code, params = {}, opts = {}) ⇒ Object

Note:

that you must also provide a :redirect_uri with most OAuth 2.0 providers

Retrieve an access token given the specified validation code.



35
36
37
38
# File 'lib/oauthio/strategy/auth_code.rb', line 35

def get_token(code, params = {}, opts = {})
  params = {'code' => code}.merge(client_params).merge(params)
  @client.get_token(params, opts)
end