Module: OmniContacts::Authorization::OAuth2

Includes:
HTTPUtils
Included in:
Middleware::OAuth2
Defined in:
lib/omnicontacts/authorization/oauth2.rb

Constant Summary

Constants included from HTTPUtils

HTTPUtils::SSL_PORT

Instance Method Summary collapse

Methods included from HTTPUtils

encode, host_url_from_rack_env, query_string_to_map, scheme, to_query_string

Instance Method Details

#authorization_urlObject

Calculates the URL the user has to be redirected to in order to authorize the application to access his contacts list.



22
23
24
# File 'lib/omnicontacts/authorization/oauth2.rb', line 22

def authorization_url
  "https://" + auth_host + authorize_path + "?" + authorize_url_params
end

#fetch_access_token(code) ⇒ Object

Fetches the access token from the authorization server using the given authorization code.



42
43
44
# File 'lib/omnicontacts/authorization/oauth2.rb', line 42

def fetch_access_token code
  access_token_from_response https_post(auth_host, auth_token_path, token_req_params(code))
end

#refresh_access_token(refresh_token) ⇒ Object

Refreshes the access token using the provided refresh_token.



70
71
72
# File 'lib/omnicontacts/authorization/oauth2.rb', line 70

def refresh_access_token refresh_token
  access_token_from_response https_post(auth_host, auth_token_path, refresh_token_req_params(refresh_token))
end