Class: OmniAuth::Strategies::SoundCloud

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

Overview

Authenticate to SoundCloud via OAuth and retrieve basic user information.

Usage:

use OmniAuth::Strategies::SoundCloud, '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) ⇒ SoundCloud

Returns a new instance of SoundCloud.



16
17
18
# File 'lib/omniauth/strategies/sound_cloud.rb', line 16

def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
  super(app, :soundcloud, consumer_key, consumer_secret, {:site => 'https://api.soundcloud.com'}, options)
end

Instance Method Details

#auth_hashObject



20
21
22
23
24
25
26
# File 'lib/omniauth/strategies/sound_cloud.rb', line 20

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

#user_hashObject



41
42
43
# File 'lib/omniauth/strategies/sound_cloud.rb', line 41

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

#user_infoObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/omniauth/strategies/sound_cloud.rb', line 28

def 
  user_hash = self.user_hash
  
  {
    'name' => user_hash['full_name'],
    'nickname' => user_hash['username'],
    'location' => user_hash['city'],
    'description' => user_hash['description'],
    'image' => user_hash['avatar_url'],
    'urls' => {'Website' => user_hash['website']}
  }
end