module GogoKit::Client::OAuth
OAuth
authentication methods for {GogoKit::Client}
Public Instance Methods
get_access_token(grant_type, options = {})
click to toggle source
Get an OAuth
access token
@see viagogo.github.io/developer.viagogo.net/#authentication @param [String] grant_type The grant type to use to get the token @param [Hash] options Token request information @return [GogoKit::OAuthToken] The OAuth
token
# File lib/gogokit/client/oauth.rb, line 72 def get_access_token(grant_type, options = {}) object_from_response(GogoKit::OAuthToken, GogoKit::OAuthTokenRepresenter, :post, oauth_token_endpoint, body: token_request_body(grant_type, options), headers: token_request_headers) end
get_client_access_token(options = {})
click to toggle source
Get an OAuth
access token for an application.
@see developer.viagogo.net/#application-only-authentication-flow @param [Hash] options Token request information @return [GogoKit::OAuthToken] The OAuth
token
# File lib/gogokit/client/oauth.rb, line 53 def get_client_access_token(options = {}) get_access_token('client_credentials', options) end
get_refresh_token(token, options = {})
click to toggle source
Obtain additional access tokens in order to prolong access to a users data @param [GogoKit::OAuthToken] token The token to be refreshed.
# File lib/gogokit/client/oauth.rb, line 60 def get_refresh_token(token, options = {}) merged_options = options.merge(refresh_token: token.refresh_token, scope: token.scope) get_access_token('refresh_token', merged_options) end
Private Instance Methods
token_request_body(grant_type, options)
click to toggle source
# File lib/gogokit/client/oauth.rb, line 83 def token_request_body(grant_type, options) body = options || {} body[:grant_type] = grant_type body end
token_request_headers()
click to toggle source
# File lib/gogokit/client/oauth.rb, line 89 def token_request_headers credentials = "#{client_id}:#{client_secret}" basic_header_value = Base64.encode64(credentials).delete("\n") { content_type: 'application/x-www-form-urlencoded', accept: 'application/json', authorization: "Basic #{basic_header_value}" } end