Class: Bloopi::API::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/bloopi/api/auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id = nil, client_secret = nil) ⇒ Auth

Creates a new client.

Parameters:

  • client_id (String, Integer) (defaults to: nil)

    a Bloopi client ID

  • client_secret (defaults to: nil)

    a Bloopi client secret



14
15
16
17
# File 'lib/bloopi/api/auth.rb', line 14

def initialize(client_id = nil, client_secret = nil)
  @client_id = client_id || Bloopi.config.client_id
  @client_secret = client_secret || Bloopi.config.client_secret
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



8
9
10
# File 'lib/bloopi/api/auth.rb', line 8

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



8
9
10
# File 'lib/bloopi/api/auth.rb', line 8

def client_secret
  @client_secret
end

Instance Method Details

#get_access_token(options = {}) ⇒ Object

Fetches the application’s access token (ignoring expiration and other info).

Returns:

  • the application access token

See Also:

  • get_app_access_token_info


44
45
46
47
48
# File 'lib/bloopi/api/auth.rb', line 44

def get_access_token(options = {})
  if info = get_access_token_info(options)
    Bloopi.config.access_token = info["access_token"]
  end
end

#get_access_token_info(options = {}) ⇒ Object

Fetches an access token, token expiration, and other info from Bloopi. Useful when you’ve received an OAuth code using the server-side authentication process.

Parameters:

  • options (defaults to: {})

    any additional parameters to send to Bloopi when redeeming the token

Returns:

  • a hash of the access token info returned by Bloopi (token, expiration, etc.)

Raises:

  • Bloopi::OAuthTokenRequestError if Bloopi returns an error response

See Also:

  • url_for_oauth_code


33
34
35
36
# File 'lib/bloopi/api/auth.rb', line 33

def get_access_token_info(options = {})
  # convenience method to get a the application's sessionless access token
   get_token_from_server({}, true, options)
end