Class: OmniAuth::Strategies::Bitly

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/oauth2/bitly.rb

Overview

Authenticate to Bitly utilizing OAuth 2.0 and retrieve basic user information.

Examples:

Basic Usage

use OmniAuth::Strategies::Bitly, 'API Key', 'Secret Key'

Instance Attribute Summary

Attributes inherited from OAuth2

#client_id, #client_options, #client_secret, #options

Instance Method Summary collapse

Methods inherited from OAuth2

#callback_url, #client

Constructor Details

#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Bitly

Returns a new instance of Bitly.

Parameters:

  • app (Rack Application)

    standard middleware application parameter

  • client_id (String) (defaults to: nil)

    the application id as registered on Bitly

  • client_secret (String) (defaults to: nil)

    the application secret as registered on Bitly



15
16
17
18
19
20
21
# File 'lib/omniauth/strategies/oauth2/bitly.rb', line 15

def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
  client_options = {
    :authorize_url => 'https://bit.ly/oauth/authorize',
    :token_url => 'https://api-ssl.bit.ly/oauth/access_token',
  }
  super(app, :bitly, client_id, client_secret, client_options, options, &block)
end

Instance Method Details

#auth_hashObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/omniauth/strategies/oauth2/bitly.rb', line 23

def auth_hash
  OmniAuth::Utils.deep_merge(
    super, {
      'uid' => @access_token['login'],
      'user_info' => user_data,
      'extra' => {
        'user_hash' => user_data,
      },
    }
  )
end

#user_dataObject



35
36
37
38
39
40
# File 'lib/omniauth/strategies/oauth2/bitly.rb', line 35

def user_data
  {
    'login' => @access_token['login'],
    'client_id' => @access_token['apiKey'],
  }
end