Class: LedgerSync::Adaptors::QuickBooksOnline::OAuthClient
- Inherits:
-
Object
- Object
- LedgerSync::Adaptors::QuickBooksOnline::OAuthClient
show all
- Defined in:
- lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb
Defined Under Namespace
Classes: RedirectURIParser
Constant Summary
collapse
- AUTHORIZE_URL =
'https://appcenter.intuit.com/connect/oauth2'
- SITE_URL =
'https://appcenter.intuit.com/connect/oauth2'
- TOKEN_URL =
'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client_id:, client_secret:) ⇒ OAuthClient
Returns a new instance of OAuthClient.
49
50
51
52
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb', line 49
def initialize(client_id:, client_secret:)
@client_id = client_id
@client_secret = client_secret
end
|
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
46
47
48
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb', line 46
def client_id
@client_id
end
|
#client_secret ⇒ Object
Returns the value of attribute client_secret.
46
47
48
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb', line 46
def client_secret
@client_secret
end
|
Class Method Details
.new_from_env ⇒ Object
84
85
86
87
88
89
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb', line 84
def self.new_from_env
new(
client_id: ENV.fetch('QUICKBOOKS_ONLINE_CLIENT_ID'),
client_secret: ENV.fetch('QUICKBOOKS_ONLINE_CLIENT_SECRET')
)
end
|
Instance Method Details
#auth_code ⇒ Object
63
64
65
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb', line 63
def auth_code
client.auth_code
end
|
#authorization_url(redirect_uri:) ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb', line 54
def authorization_url(redirect_uri:)
client.auth_code.authorize_url(
redirect_uri: redirect_uri,
response_type: 'code',
state: SecureRandom.hex(12),
scope: 'com.intuit.quickbooks.accounting'
)
end
|
#client ⇒ Object
67
68
69
70
71
72
73
74
75
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb', line 67
def client
@client ||= OAuth2::Client.new(
client_id,
client_secret,
authorize_url: AUTHORIZE_URL,
site: SITE_URL,
token_url: TOKEN_URL
)
end
|
#get_token(code:, redirect_uri:) ⇒ Object
77
78
79
80
81
82
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb', line 77
def get_token(code:, redirect_uri:)
auth_code.get_token(
code,
redirect_uri: redirect_uri
)
end
|