Module: SageOne::OAuth
- Included in:
- Client
- Defined in:
- lib/sage_one/oauth.rb
Overview
This module helps with setting up the OAuth connection to SageOne. After the two step process you will have an access_token that you can store and use for making future API calls.
Instance Method Summary collapse
-
#authorize_url(callback_url) ⇒ String
Generates the OAuth URL for redirecting users to SageOne.
-
#get_access_token(code, callback_url) ⇒ Hashie::Mash
Returns an access token for future authentication.
Instance Method Details
#authorize_url(callback_url) ⇒ String
Generates the OAuth URL for redirecting users to SageOne. You should ensure the your SageOne.client_id is configured before calling this method.
21 22 23 24 25 26 27 28 |
# File 'lib/sage_one/oauth.rb', line 21 def (callback_url) params = { client_id: client_id, redirect_uri: callback_url, response_type: 'code' } connection.build_url("/oauth/authorize/", params).to_s end |
#get_access_token(code, callback_url) ⇒ Hashie::Mash
Returns an access token for future authentication.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sage_one/oauth.rb', line 38 def get_access_token(code, callback_url) params = { client_id: client_id, client_secret: client_secret, grant_type: 'authorization_code', code: code, redirect_uri: callback_url } post("/oauth/token/", params) end |