Class: Increase::Resources::OAuthTokens

Inherits:
Object
  • Object
show all
Defined in:
lib/increase/resources/oauth_tokens.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ OAuthTokens

Returns a new instance of OAuthTokens.



6
7
8
# File 'lib/increase/resources/oauth_tokens.rb', line 6

def initialize(client:)
  @client = client
end

Instance Method Details

#create(params = {}, opts = {}) ⇒ Increase::Models::OAuthToken

Create an OAuth Token

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :grant_type (Symbol)

    The credential you request in exchange for the code. In Production, this is always authorization_code. In Sandbox, you can pass either enum value.

  • :client_id (String)

    The public identifier for your application.

  • :client_secret (String)

    The secret that confirms you own the application. This is redundent given that the request is made with your API key but it's a required component of OAuth 2.0.

  • :code (String)

    The authorization code generated by the user and given to you as a query parameter.

  • :production_token (String)

    The production token you want to exchange for a sandbox token. This is only available in Sandbox. Set grant_type to production_token to use this parameter.

Returns:



28
29
30
31
32
33
34
35
# File 'lib/increase/resources/oauth_tokens.rb', line 28

def create(params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/oauth/tokens"
  req[:body] = params
  req[:model] = Increase::Models::OAuthToken
  @client.request(req, opts)
end