Class: OAuth2::Grant::Base
- Inherits:
-
Object
- Object
- OAuth2::Grant::Base
- Includes:
- UrlHelper
- Defined in:
- lib/oauth2/grant/base.rb
Direct Known Subclasses
AuthorizationCode, ClientCredentials, DeviceCode, Implicit, Password, RefreshToken
Defined Under Namespace
Classes: InvalidAuthorizationTypeError
Instance Attribute Summary collapse
-
#authorize_path ⇒ Object
Returns the value of attribute authorize_path.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#device_path ⇒ Object
Returns the value of attribute device_path.
-
#host ⇒ Object
Returns the value of attribute host.
-
#token_path ⇒ Object
Returns the value of attribute token_path.
Instance Method Summary collapse
-
#initialize(client) ⇒ Base
constructor
A new instance of Base.
- #make_request(method, path, opts = {}) ⇒ Object
Methods included from UrlHelper
#build_url, #generate_timestamp, #generate_urlsafe_key, http_basic_encode, #to_query
Constructor Details
#initialize(client) ⇒ Base
11 12 13 14 15 16 17 18 19 |
# File 'lib/oauth2/grant/base.rb', line 11 def initialize(client) @host = client.host @connection = client.connection @client_id = client.client_id @client_secret = client.client_secret @token_path = client.token_path = client. @device_path = client.device_path end |
Instance Attribute Details
#authorize_path ⇒ Object
Returns the value of attribute authorize_path.
8 9 10 |
# File 'lib/oauth2/grant/base.rb', line 8 def end |
#client_id ⇒ Object
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/oauth2/grant/base.rb', line 8 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
8 9 10 |
# File 'lib/oauth2/grant/base.rb', line 8 def client_secret @client_secret end |
#connection ⇒ Object
Returns the value of attribute connection.
8 9 10 |
# File 'lib/oauth2/grant/base.rb', line 8 def connection @connection end |
#device_path ⇒ Object
Returns the value of attribute device_path.
8 9 10 |
# File 'lib/oauth2/grant/base.rb', line 8 def device_path @device_path end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/oauth2/grant/base.rb', line 8 def host @host end |
#token_path ⇒ Object
Returns the value of attribute token_path.
8 9 10 |
# File 'lib/oauth2/grant/base.rb', line 8 def token_path @token_path end |
Instance Method Details
#make_request(method, path, opts = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/oauth2/grant/base.rb', line 21 def make_request(method, path, opts={}) if auth_type = opts.delete(:authenticate) case auth_type.to_sym when :body opts[:params] ||= {} opts[:params].merge!({ :client_id => @client_id, :client_secret => @client_secret }) when :headers opts[:headers] ||= {} opts[:headers]['Authorization'] = http_basic_encode(@client_id, @client_secret) else #do nothing end end @connection.send_request(method, path, opts) end |