Class: Ebay::Oauth::ClientCredentialsGrant
- Inherits:
-
Object
- Object
- Ebay::Oauth::ClientCredentialsGrant
- Includes:
- Requestable
- Defined in:
- lib/ebay/oauth/client_credentials_grant.rb
Overview
Mints an access token to use in API requests
Instance Attribute Summary collapse
- #app_id ⇒ String readonly
- #cert_id ⇒ String readonly
Attributes included from Requestable
Instance Method Summary collapse
-
#initialize(app_id: Config.app_id, cert_id: Config.cert_id) ⇒ ClientCredentialsGrant
constructor
A new instance of ClientCredentialsGrant.
-
#mint_access_token ⇒ String
Mints a new access token.
-
#request ⇒ HTTP::Response
Requests a client credentials grant.
Methods included from Requestable
#market_id=, #persistent, #sandbox, #use, #via
Constructor Details
#initialize(app_id: Config.app_id, cert_id: Config.cert_id) ⇒ ClientCredentialsGrant
Returns a new instance of ClientCredentialsGrant.
24 25 26 27 |
# File 'lib/ebay/oauth/client_credentials_grant.rb', line 24 def initialize(app_id: Config.app_id, cert_id: Config.cert_id) @app_id = app_id @cert_id = cert_id end |
Instance Attribute Details
#app_id ⇒ String (readonly)
17 18 19 |
# File 'lib/ebay/oauth/client_credentials_grant.rb', line 17 def app_id @app_id end |
#cert_id ⇒ String (readonly)
20 21 22 |
# File 'lib/ebay/oauth/client_credentials_grant.rb', line 20 def cert_id @cert_id end |
Instance Method Details
#mint_access_token ⇒ String
Mints a new access token
32 33 34 |
# File 'lib/ebay/oauth/client_credentials_grant.rb', line 32 def mint_access_token JSON.parse(request).fetch('access_token') end |
#request ⇒ HTTP::Response
Requests a client credentials grant
39 40 41 42 |
# File 'lib/ebay/oauth/client_credentials_grant.rb', line 39 def request http.basic_auth(user: app_id, pass: cert_id) .post(endpoint, form: payload) end |