lib/bearcat/client/o_auth2.rb in bearcat-1.1.1 vs lib/bearcat/client/o_auth2.rb in bearcat-1.2.0
- old
+ new
@@ -13,20 +13,26 @@
query << ['scopes', scopes] if scopes
uri.query = URI.encode_www_form(query)
uri.to_s
end
- def retrieve_token(client_id, redirect_url, client_secret, code)
- body = post('/login/oauth2/token', {
+ def retrieve_token(client_id, redirect_url, client_secret, code, grant_type = 'authorization_code')
+ token_params = {
client_id: client_id,
redirect_url: redirect_url,
client_secret: client_secret,
- code: code
- })
+ grant_type: grant_type
+ }
+ if grant_type == 'authorization_code'
+ token_params[:code] = code
+ elsif grant_type == 'refresh_token'
+ token_params[:refresh_token] = code
+ end
+ body = post('/login/oauth2/token', token_params)
config[:token] = body['access_token']
set_connection(config)
- config[:token]
+ body
end
end
end
-end
\ No newline at end of file
+end