module Googol::Authenticable::ClassMethods
Public Instance Methods
oauth_scopes()
click to toggle source
Set the scopes to grant access to an account. This method is meant to be overridden.
# File lib/googol/authenticable.rb, line 96 def oauth_scopes end
oauth_url(redirect_url = 'http://example.com/')
click to toggle source
Returns the URL for users to authorize this app to access their account
@param [String] redirect_url The page to redirect after the OAuth2 page
@return [String] URL of the OAuth2 Authorization page.
@note The redirect_url must match one of the redirect URLs whitelisted
for the app in the Google Developers Console
@see console.developers.google.com
# 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