Module: Vm::Authenticable

Includes:
ClientTokens, Requestable
Included in:
VimeoAccount
Defined in:
lib/vm/authenticable.rb

Overview

Provides methods to authenticate as an account (either Vimeo or Vimeo).

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Requestable

#request!

Methods included from ClientTokens

#client_id, client_id=, #client_secret, client_secret=

Instance Method Details

#credentialsHash

Return the authorization credentials of an account for this app.

Returns:

  • (Hash)
    • :client_id [String] …

    • :client_secret [String] …

See Also:

  • ...

34
35
36
37
38
39
40
# File 'lib/vm/authenticable.rb', line 34

def credentials
  @credentials ||= request! method: :post,
    host: 'https://accounts.google.com',
    path: '/o/oauth2/token',
    body: credentials_params,
    valid_if: -> response, body {response.code == '200'}
end

#initialize(attrs = {}) ⇒ Object

Initialize an object with either an authorization code or a refresh token

Parameters:

  • attrs (Hash) (defaults to: {})

    Authentication credentials to access the account

Options Hash (attrs):

  • :code (String)

    The OAuth2 authorization code

  • :redirect_url (String)

    The page to redirect after the OAuth2 page

  • :refresh_token (String)

    The refresh token for offline access

See Also:


20
21
22
23
24
# File 'lib/vm/authenticable.rb', line 20

def initialize(attrs = {})
  @code = attrs[:code]
  @refresh_token = attrs[:refresh_token]
  @redirect_url = attrs.fetch :redirect_url, 'http://example.com/'
end