Class: Authentication
Constant Summary collapse
- ACCESS_TOKEN_URL =
'https://developer.globelabs.com.ph/oauth/access_token'
- REDIRECT_URL =
'https://developer.globelabs.com.ph/dialog/oauth?app_id=%s'
Instance Method Summary collapse
-
#get_access_token(app_id, app_secret, code) ⇒ Object
Requests for an access token based on the given app id, app secret, and code that was returned after logging in via WebForm.
-
#get_access_url(app_id) ⇒ Object
Generates the url where the application/user will login.
Methods inherited from Base
#send_get_request, #send_post_request
Instance Method Details
#get_access_token(app_id, app_secret, code) ⇒ Object
Requests for an access token based on the given app id, app secret, and code that was returned after logging in via WebForm
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/globe_connect/authentication.rb', line 13 def get_access_token(app_id, app_secret, code) url = ACCESS_TOKEN_URL # set body query = { "app_id" => app_id, "app_secret" => app_secret, "code" => code } # hash it payload = URI.encode(query.map{|k,v| "#{k}=#{v}"}.join("&")) # send post request response = send_post_request(url, payload, 'application/x-www-form-urlencoded') return JSON.parse(response) end |
#get_access_url(app_id) ⇒ Object
Generates the url where the application/user will login
36 37 38 |
# File 'lib/globe_connect/authentication.rb', line 36 def get_access_url(app_id) return sprintf(REDIRECT_URL, app_id) end |