Class: Tandarb::Oauth
Constant Summary
collapse
- BASE_URL =
'https://my.tanda.co/api/oauth'.freeze
- TOKEN_URL =
"#{BASE_URL}/token".freeze
Class Method Summary
collapse
Methods inherited from Client
#delete, #get, #post, #put
Class Method Details
.authorize(scope, client_id, redirect_uri) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/tandarb/oauth.rb', line 6
def self.authorize(scope, client_id, redirect_uri)
url = "#{BASE_URL}/authorize?scope=#{scope}&client_id=#{client_id}"
url += "&response_type=code&redirect_uri=#{redirect_uri}"
HTTParty.get(url).parsed_response
end
|
.refresh_token(client_id, client_secret, refresh_token, redirect_uri) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/tandarb/oauth.rb', line 25
def self.refresh_token(client_id, client_secret, refresh_token, redirect_uri)
body = {
client_id: client_id,
client_secret: client_secret,
refresh_token: refresh_token,
redirect_uri: redirect_uri,
grant_type: 'refresh_token'
}
HTTParty.post(TOKEN_URL, body: body).parsed_response
end
|
.request_token(code: code, client_id: client_id, client_secret: client_secret, redirect_uri: redirect_uri) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/tandarb/oauth.rb', line 13
def self.request_token(code: code, client_id: client_id, client_secret: client_secret, redirect_uri: redirect_uri)
body = {
code: code,
client_id: client_id,
client_secret: client_secret,
redirect_uri: redirect_uri,
grant_type: 'authorization_code'
}
HTTParty.post(TOKEN_URL, body: body).parsed_response
end
|