Class: IntuitOAuth::Flow::AuthCode

Inherits:
Base
  • Object
show all
Defined in:
lib/intuit-oauth/flow/code.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from IntuitOAuth::Base

Instance Method Details

#get_auth_uri(scopes, state_token = nil) ⇒ URL

Generate the Authorization Code URL

Parameters:

  • the (Scope)

    Scope for the token to be generated

  • an (state_token)

    option state token to be passed

Returns:

  • (URL)

    the authorization code URL


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/intuit-oauth/flow/code.rb', line 29

def get_auth_uri(scopes, state_token=nil)
  if state_token.nil?
    state_token = IntuitOAuth::Utils.generate_random_string()
  end
  @client.state_token = state_token
  url_params = {
    client_id: @client.id,
    scope: IntuitOAuth::Utils.scopes_to_string(scopes),
    redirect_uri: @client.redirect_uri,
    response_type: 'code',
    state: state_token,
  }

  "#{@client.auth_endpoint}?#{url_params.to_param}"
end