Module: Vm::Authenticable::ClassMethods

Includes:
ClientTokens
Defined in:
lib/vm/authenticable.rb

Instance Method Summary collapse

Methods included from ClientTokens

#client_id, client_id=, #client_secret, client_secret=

Instance Method Details

#oauth_scopesObject

Set the scopes to grant access to an account. This method is meant to be overridden.



92
93
# File 'lib/vm/authenticable.rb', line 92

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 Vimeo Developers Console

Returns the URL for users to authorize this app to access their account

Parameters:

  • redirect_url (String) (defaults to: 'http://example.com/')

    The page to redirect after the OAuth2 page

Returns:

  • (String)

    URL of the OAuth2 Authorization page.

See Also:



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/vm/authenticable.rb', line 76

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