class IntuitOAuth::Flow::AuthCode

Public Instance Methods

get_auth_uri(scopes, state_token=nil) click to toggle source

Generate the Authorization Code URL

@param [Scope] the Scope for the token to be generated @param [state_token] an option state token to be passed @return [URL] the authorization code URL

# 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