Module: Googol::Authenticable::ClassMethods
- Includes:
- ClientTokens
- Defined in:
- lib/googol/authenticable.rb
Instance Method Summary collapse
-
#oauth_scopes ⇒ Object
Set the scopes to grant access to an account.
-
#oauth_url(redirect_url = 'http://example.com/') ⇒ String
Returns the URL for users to authorize this app to access their account.
Methods included from ClientTokens
#client_id, client_id=, #client_secret, client_secret=
Instance Method Details
#oauth_scopes ⇒ Object
Set the scopes to grant access to an account. This method is meant to be overridden.
96 97 |
# File 'lib/googol/authenticable.rb', line 96 def oauth_scopes end |
#oauth_url(redirect_url = 'http://example.com/') ⇒ String
Note:
The redirect_url must match one of the redirect URLs whitelisted for the app in the Google Developers Console
Returns the URL for users to authorize this app to access their account
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/googol/authenticable.rb', line 80 def oauth_url(redirect_url = 'http://example.com/') params = { client_id: client_id, scope: oauth_scopes.join(' '), redirect_uri: redirect_url, response_type: :code, access_type: :offline, approval_prompt: :force } q = params.map{|k,v| "#{CGI.escape k.to_s}=#{CGI.escape v.to_s}"}.join '&' args = {host: 'accounts.google.com', path: '/o/oauth2/auth', query: q} URI::HTTPS.build(args).to_s end |