Module: GogoKit::Client::OAuth
Overview
OAuth authentication methods for GogoKit::Client
Instance Method Summary collapse
-
#get_access_token(grant_type, options = {}) ⇒ GogoKit::OAuthToken
Get an OAuth access token.
-
#get_authorization_code_access_token(code, redirect_uri, scopes, options = {}) ⇒ Object
Requests an access token that will provide access to user-specific data (sales, sellerlistings, webhooks, purchases, etc) applications return URL.
-
#get_authorization_url(redirect_uri, scopes, state = nil) ⇒ Object
Gets the URL where applications can obtain a users consent to make API calls on their behalf.
-
#get_client_access_token(options = {}) ⇒ GogoKit::OAuthToken
Get an OAuth access token for an application.
-
#get_refresh_token(token, options = {}) ⇒ Object
Obtain additional access tokens in order to prolong access to a users data.
Methods included from Utils
Instance Method Details
#get_access_token(grant_type, options = {}) ⇒ GogoKit::OAuthToken
Get an OAuth access token
72 73 74 75 76 77 78 79 |
# File 'lib/gogokit/client/oauth.rb', line 72 def get_access_token(grant_type, = {}) object_from_response(GogoKit::OAuthToken, GogoKit::OAuthTokenRepresenter, :post, oauth_token_endpoint, body: token_request_body(grant_type, ), headers: token_request_headers) end |
#get_authorization_code_access_token(code, redirect_uri, scopes, options = {}) ⇒ Object
Requests an access token that will provide access to user-specific data (sales, sellerlistings, webhooks, purchases, etc) applications return URL. authorization code is sent. This must match the URL registered for your application. needed.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gogokit/client/oauth.rb', line 37 def (code, redirect_uri, scopes, = {}) scope_value = scopes.nil? ? '' : scopes.join(' ') = .merge(code: code, redirect_uri: redirect_uri, scope: scope_value) get_access_token('authorization_code', ) end |
#get_authorization_url(redirect_uri, scopes, state = nil) ⇒ Object
Gets the URL where applications can obtain a users consent to make API calls on their behalf. authorization code is sent. This must match the URL registered for your application. needed. authorize request and the callback.
21 22 23 24 25 |
# File 'lib/gogokit/client/oauth.rb', line 21 def (redirect_uri, scopes, state = nil) scope_value = scopes.nil? ? '' : scopes.join('%20') "#{}?client_id=#{client_id}&response_type=code&" \ "redirect_uri=#{redirect_uri}&scope=#{scope_value}&state=#{state}" end |
#get_client_access_token(options = {}) ⇒ GogoKit::OAuthToken
Get an OAuth access token for an application.
53 54 55 |
# File 'lib/gogokit/client/oauth.rb', line 53 def get_client_access_token( = {}) get_access_token('client_credentials', ) end |
#get_refresh_token(token, options = {}) ⇒ Object
Obtain additional access tokens in order to prolong access to a users data
60 61 62 63 64 |
# File 'lib/gogokit/client/oauth.rb', line 60 def get_refresh_token(token, = {}) = .merge(refresh_token: token.refresh_token, scope: token.scope) get_access_token('refresh_token', ) end |