Class: OmniAuth::Strategies::Viadeo
- Defined in:
- lib/omniauth/strategies/oauth2/viadeo.rb
Overview
Authenticate to Viadeo utilizing OAuth 2.0 and retrieve basic user information.
Instance Attribute Summary
Attributes inherited from OAuth2
#client_id, #client_options, #client_secret, #options
Instance Method Summary collapse
- #auth_hash ⇒ Object
- #callback_phase ⇒ Object
-
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Viadeo
constructor
A new instance of Viadeo.
- #request_phase ⇒ Object
- #user_data ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth2
Constructor Details
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Viadeo
Returns a new instance of Viadeo.
15 16 17 18 19 20 21 22 |
# File 'lib/omniauth/strategies/oauth2/viadeo.rb', line 15 def initialize(app, client_id=nil, client_secret=nil, = {}, &block) = { :site => 'https://api.viadeo.com/', :authorize_url => 'https://secure.viadeo.com/oauth-provider/authorize2', :token_url => 'https://secure.viadeo.com/oauth-provider/access_token2' } super(app, :viadeo, client_id, client_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/omniauth/strategies/oauth2/viadeo.rb', line 24 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_data, }, } ) end |
#callback_phase ⇒ Object
45 46 47 48 |
# File 'lib/omniauth/strategies/oauth2/viadeo.rb', line 45 def callback_phase [:grant_type] ||= 'authorization_code' super end |
#request_phase ⇒ Object
40 41 42 43 |
# File 'lib/omniauth/strategies/oauth2/viadeo.rb', line 40 def request_phase [:response_type] ||= 'code' super end |
#user_data ⇒ Object
36 37 38 |
# File 'lib/omniauth/strategies/oauth2/viadeo.rb', line 36 def user_data @data ||= MultiJson.decode(@access_token.get('/me').body) end |
#user_info ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/omniauth/strategies/oauth2/viadeo.rb', line 50 def user_info { 'name' => user_data['name'], 'link' => user_data['link'], 'first_name' => user_data['first_name'], 'last_name' => user_data['last_name'], 'gender' => user_data['gender'], 'nickname' => user_data['nickname'], 'has_picture' => user_data['has_picture'] , 'picture_small' => user_data['picture_small'], 'picture_large' => user_data['picture_large'], 'headline' => user_data['headline'], 'introduction' => user_data['introduction'], 'interests' => user_data['interests'], 'location' => user_data['location'], 'is_premium' => user_data['is_premium'], 'premium_since' => user_data['premium_since'] } end |