Class: OmniAuth::Strategies::Identica

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/identica.rb

Overview

Authenticate to Identica via OAuth and retrieve basic user information.

Usage:

use OmniAuth::Strategies::Identica, 'consumerkey', 'consumersecret'

Instance Attribute Summary

Attributes inherited from OAuth

#consumer_key, #consumer_options, #consumer_secret, #name

Instance Method Summary collapse

Methods inherited from OAuth

#callback_phase, #consumer, #request_phase, #unique_id

Constructor Details

#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Identica

Returns a new instance of Identica.



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

def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
  super(app, :identica, consumer_key, consumer_secret,
          {:site => 'http://identi.ca',
          :request_token_path => "/api/oauth/request_token",
          :access_token_path  => "/api/oauth/access_token",
          :authorize_path     => "/api/oauth/authorize"}, options, &block)
end

Instance Method Details

#auth_hashObject



23
24
25
26
27
28
29
# File 'lib/omniauth/strategies/identica.rb', line 23

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

#user_hashObject



44
45
46
# File 'lib/omniauth/strategies/identica.rb', line 44

def user_hash
  @user_hash ||= MultiJson.decode(@access_token.get('/api/account/verify_credentials.json').body)
end

#user_infoObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/omniauth/strategies/identica.rb', line 31

def 
  user_hash = self.user_hash

  {
    'nickname' => user_hash['screen_name'],
    'name' => user_hash['name'],
    'location' => user_hash['location'],
    'image' => user_hash['profile_image_url'],
    'description' => user_hash['description'],
    'urls' => {'Website' => user_hash['url']}
  }
end