Class: IntuitOAuth::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/intuit-oauth/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, redirect_uri, environment) ⇒ Client

Returns a new instance of Client.


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/intuit-oauth/client.rb', line 29

def initialize(client_id, client_secret, redirect_uri, environment)
  @id = client_id
  @secret = client_secret
  @redirect_uri = redirect_uri
  @environment = environment

  # Discovery Doc containes endpoints required for OAuth fow
  @discovery_doc = get_discovery_doc(@environment)
  @auth_endpoint = @discovery_doc['authorization_endpoint']
  @token_endpoint = @discovery_doc['token_endpoint']
  @revoke_endpoint = @discovery_doc['revocation_endpoint']
  @issuer_uri = @discovery_doc['issuer']
  @jwks_uri = @discovery_doc['jwks_uri']
  @user_info_url = @discovery_doc['userinfo_endpoint']

  # optionally set realm_id
  @realm_id = ''
  @state_token = ''
end

Instance Attribute Details

#auth_endpointObject (readonly)

Returns the value of attribute auth_endpoint


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def auth_endpoint
  @auth_endpoint
end

#environmentObject (readonly)

Returns the value of attribute environment


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def environment
  @environment
end

#idObject (readonly)

Returns the value of attribute id


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def id
  @id
end

#issuer_uriObject (readonly)

Returns the value of attribute issuer_uri


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def issuer_uri
  @issuer_uri
end

#jwks_uriObject (readonly)

Returns the value of attribute jwks_uri


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def jwks_uri
  @jwks_uri
end

#realm_idObject

Returns the value of attribute realm_id


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def realm_id
  @realm_id
end

#redirect_uriObject (readonly)

Returns the value of attribute redirect_uri


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def redirect_uri
  @redirect_uri
end

#revoke_endpointObject (readonly)

Returns the value of attribute revoke_endpoint


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def revoke_endpoint
  @revoke_endpoint
end

#secretObject (readonly)

Returns the value of attribute secret


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def secret
  @secret
end

#state_tokenObject

Returns the value of attribute state_token


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def state_token
  @state_token
end

#token_endpointObject (readonly)

Returns the value of attribute token_endpoint


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def token_endpoint
  @token_endpoint
end

#user_info_urlObject (readonly)

Returns the value of attribute user_info_url


25
26
27
# File 'lib/intuit-oauth/client.rb', line 25

def 
  @user_info_url
end

Instance Method Details

#codeObject


58
59
60
# File 'lib/intuit-oauth/client.rb', line 58

def code
  IntuitOAuth::Flow::AuthCode.new(self)
end

#get_discovery_doc(environment) ⇒ Object


49
50
51
52
53
54
55
56
# File 'lib/intuit-oauth/client.rb', line 49

def get_discovery_doc(environment)
  if ['production', 'prod'].include? environment.downcase
    url = IntuitOAuth::Config::DISCOVERY_URL_PROD
  else
    url = IntuitOAuth::Config::DISCOVERY_URL_SANDBOX
  end
  IntuitOAuth::Transport.request('GET', url)
end

#migrationObject


70
71
72
# File 'lib/intuit-oauth/client.rb', line 70

def migration
  IntuitOAuth::Migration::Migrate.new(self)
end

#openidObject


66
67
68
# File 'lib/intuit-oauth/client.rb', line 66

def openid
  IntuitOAuth::Flow::OpenID.new(self)
end

#tokenObject


62
63
64
# File 'lib/intuit-oauth/client.rb', line 62

def token
  IntuitOAuth::Flow::Token.new(self)
end