Class: RGData::Authentication
- Inherits:
-
Object
- Object
- RGData::Authentication
- Includes:
- HTTParty
- Defined in:
- lib/rgdata/authentication.rb
Class Method Summary collapse
- .get_access_token(refresh_token) ⇒ Object
-
.request_url(scope, redirect_uri) ⇒ Object
Construct a url for requesting authentication.
Class Method Details
.get_access_token(refresh_token) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rgdata/authentication.rb', line 23 def get_access_token(refresh_token) body = { refresh_token: refresh_token, grant_type: 'refresh_token', client_id: RGData.config.client_id, client_secret: RGData.config.client_secret, } body.verify_keys_present_and_values_not_nil(:refresh_token, :grant_type, :client_secret, :client_id) response = post('/token', body: body) response['access_token'] end |
.request_url(scope, redirect_uri) ⇒ Object
Construct a url for requesting authentication.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rgdata/authentication.rb', line 9 def request_url(scope, redirect_uri) method = Net::HTTP::Get path = [:base_uri] + '/auth' query = { redirect_uri: redirect_uri, scope: scope, response_type: 'code', client_id: RGData.config.client_id, } query.verify_keys_present_and_values_not_nil(:client_id, :redirect_uri, :scope, :response_type) request = HTTParty::Request.new(method, path, query: query) URI.unescape(request.uri.to_s) end |