Class: OAuth2::Grant::AuthorizationCode
- Defined in:
- lib/oauth2/grant/authorization_code.rb
Overview
Authorization Code Grant
Instance Attribute Summary
Attributes inherited from Base
#authorize_path, #client_id, #client_secret, #connection, #device_path, #host
Instance Method Summary collapse
-
#authorization_params ⇒ Object
Default authorization request parameters.
-
#authorization_path(params = {}) ⇒ Object
Authorization Request.
- #authorization_url(params = {}) ⇒ Object
-
#fetch_authorization_url(opts = {}) ⇒ Object
Retrieve page at authorization path.
-
#get_token(code, opts = {}) ⇒ Object
Retrieve an access token for a given auth code.
- #grant_type ⇒ Object
- #response_type ⇒ Object
-
#token_path(params = {}) ⇒ Object
Access Token Request.
Methods inherited from Base
Methods included from UrlHelper
#build_url, #generate_timestamp, #generate_urlsafe_key, http_basic_encode, #to_query
Constructor Details
This class inherits a constructor from OAuth2::Grant::Base
Instance Method Details
#authorization_params ⇒ Object
Default authorization request parameters
62 63 64 65 66 67 |
# File 'lib/oauth2/grant/authorization_code.rb', line 62 def { :response_type => response_type, :client_id => @client_id } end |
#authorization_path(params = {}) ⇒ Object
Authorization Request
17 18 19 20 |
# File 'lib/oauth2/grant/authorization_code.rb', line 17 def (params={}) params = params.merge() "#{@authorize_path}?#{to_query(params)}" end |
#authorization_url(params = {}) ⇒ Object
22 23 24 25 |
# File 'lib/oauth2/grant/authorization_code.rb', line 22 def (params={}) params = params.merge() build_url(host, :path => , :params => params) end |
#fetch_authorization_url(opts = {}) ⇒ Object
Retrieve page at authorization path
39 40 41 42 43 |
# File 'lib/oauth2/grant/authorization_code.rb', line 39 def (opts={}) opts[:params] = opts.fetch(:params, {}).merge() method = opts.delete(:method) || :get make_request(method, @authorize_path, opts) end |
#get_token(code, opts = {}) ⇒ Object
Retrieve an access token for a given auth code
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/oauth2/grant/authorization_code.rb', line 50 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 |
#grant_type ⇒ Object
11 12 13 |
# File 'lib/oauth2/grant/authorization_code.rb', line 11 def grant_type "authorization_code" end |
#response_type ⇒ Object
7 8 9 |
# File 'lib/oauth2/grant/authorization_code.rb', line 7 def response_type "code" end |
#token_path(params = {}) ⇒ Object
Access Token Request
29 30 31 32 33 34 |
# File 'lib/oauth2/grant/authorization_code.rb', line 29 def token_path(params={}) unless params.empty? return "#{@token_path}?#{to_query(params)}" end @token_path end |