omniauth-soundcloud 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +44 -0
- data/lib/omniauth/soundcloud/version.rb +1 -1
- data/lib/omniauth/strategies/soundcloud.rb +14 -14
- data/omniauth-soundcloud.gemspec +1 -1
- data/spec/omniauth/strategies/soundcloud_spec.rb +30 -1
- metadata +25 -16
data/README.md
CHANGED
@@ -22,6 +22,50 @@ Then `bundle install`.
|
|
22
22
|
|
23
23
|
Supports the Server-side Flow as described in the the [SoundCloud docs](http://developers.soundcloud.com/docs/api/authentication#authorization-code-flow).
|
24
24
|
|
25
|
+
## Auth Hash
|
26
|
+
|
27
|
+
Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
28
|
+
```ruby
|
29
|
+
{
|
30
|
+
"provider" => "soundcloud",
|
31
|
+
"uid" => 12345678,
|
32
|
+
"info" => {
|
33
|
+
"name" => "Soundcloud User",
|
34
|
+
"nickname" => "soundclouder",
|
35
|
+
"image" => "https://the.image.url",
|
36
|
+
"location" => "Soundcloud Town"
|
37
|
+
},
|
38
|
+
"credentials" => {
|
39
|
+
"token" => "123-321",
|
40
|
+
"expires" => false
|
41
|
+
},
|
42
|
+
"extra" => {
|
43
|
+
"raw_info" => {
|
44
|
+
"id" => 12345678,
|
45
|
+
"kind" => "user",
|
46
|
+
"permalink" => "soundclouder",
|
47
|
+
"username" => "soundclouder",
|
48
|
+
"full_name" => "Soundcloud User",
|
49
|
+
"uri" => "https://api.soundcloud.com/users/12345678",
|
50
|
+
"permalink_url" => "http://soundcloud.com/soundclouder",
|
51
|
+
"avatar_url" => "https://the.image.url",
|
52
|
+
"country" => "United States",
|
53
|
+
"city" => "Soundcloud Town",
|
54
|
+
"online" => true,
|
55
|
+
"track_count" => 23,
|
56
|
+
"playlist_count" => 12,
|
57
|
+
"public_favorites_count" => 123,
|
58
|
+
"followers_count" => 321,
|
59
|
+
"followings_count" => 234,
|
60
|
+
"plan" => "Free",
|
61
|
+
"private_tracks_count" => 0,
|
62
|
+
"private_playlists_count" => 0,
|
63
|
+
"primary_email_confirmed" => true
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
```
|
68
|
+
|
25
69
|
## License
|
26
70
|
|
27
71
|
Copyright (c) 2011 by Lee Martin and SoundCloud
|
@@ -4,22 +4,22 @@ module OmniAuth
|
|
4
4
|
module Strategies
|
5
5
|
class SoundCloud < OmniAuth::Strategies::OAuth2
|
6
6
|
DEFAULT_SCOPE = 'non-expiring'
|
7
|
-
|
7
|
+
|
8
8
|
option :name, "soundcloud"
|
9
|
-
|
9
|
+
|
10
10
|
option :client_options, {
|
11
11
|
:site => 'https://api.soundcloud.com',
|
12
12
|
:authorize_url => '/connect',
|
13
13
|
:token_url => '/oauth2/token'
|
14
14
|
}
|
15
|
-
|
15
|
+
|
16
16
|
option :access_token_options, {
|
17
17
|
:header_format => 'OAuth %s',
|
18
18
|
:param_name => 'access_token'
|
19
19
|
}
|
20
|
-
|
20
|
+
|
21
21
|
uid { raw_info['id'] }
|
22
|
-
|
22
|
+
|
23
23
|
info do
|
24
24
|
prune!({
|
25
25
|
'nickname' => raw_info['username'],
|
@@ -32,24 +32,24 @@ module OmniAuth
|
|
32
32
|
'location' => raw_info['city']
|
33
33
|
})
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
credentials do
|
37
37
|
prune!({
|
38
38
|
'expires' => access_token.expires?,
|
39
39
|
'expires_at' => access_token.expires_at
|
40
40
|
})
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
extra do
|
44
44
|
prune!({
|
45
45
|
'raw_info' => raw_info
|
46
46
|
})
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def raw_info
|
50
50
|
@raw_info ||= access_token.get('/me.json').parsed
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def build_access_token
|
54
54
|
super.tap do |token|
|
55
55
|
token.options.merge!(access_token_options)
|
@@ -62,19 +62,19 @@ module OmniAuth
|
|
62
62
|
|
63
63
|
def authorize_params
|
64
64
|
super.tap do |params|
|
65
|
-
|
65
|
+
%w[display state scope].each { |v| params[v.to_sym] = request.params[v] if request.params[v] }
|
66
66
|
params[:scope] ||= DEFAULT_SCOPE
|
67
67
|
end
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
private
|
71
|
-
|
71
|
+
|
72
72
|
def prune!(hash)
|
73
|
-
hash.delete_if do |_, value|
|
73
|
+
hash.delete_if do |_, value|
|
74
74
|
prune!(value) if value.is_a?(Hash)
|
75
75
|
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
76
76
|
end
|
77
|
-
end
|
77
|
+
end
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/omniauth-soundcloud.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
16
16
|
s.require_paths = ['lib']
|
17
17
|
|
18
|
-
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.
|
18
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.0'
|
19
19
|
|
20
20
|
s.add_development_dependency 'rspec', '~> 2.7.0'
|
21
21
|
s.add_development_dependency 'rake'
|
@@ -2,8 +2,17 @@ require 'spec_helper'
|
|
2
2
|
require 'omniauth-soundcloud'
|
3
3
|
|
4
4
|
describe OmniAuth::Strategies::SoundCloud do
|
5
|
+
let(:request) do
|
6
|
+
double('request',
|
7
|
+
:params => {},
|
8
|
+
:cookies => {},
|
9
|
+
:env => {})
|
10
|
+
end
|
11
|
+
|
5
12
|
subject do
|
6
|
-
OmniAuth::Strategies::SoundCloud.new(nil, @options || {})
|
13
|
+
OmniAuth::Strategies::SoundCloud.new(nil, @options || {}).tap do |strategy|
|
14
|
+
strategy.stub(:request => request)
|
15
|
+
end
|
7
16
|
end
|
8
17
|
|
9
18
|
it_should_behave_like 'an oauth2 strategy'
|
@@ -27,4 +36,24 @@ describe OmniAuth::Strategies::SoundCloud do
|
|
27
36
|
subject.callback_path.should eq('/auth/soundcloud/callback')
|
28
37
|
end
|
29
38
|
end
|
39
|
+
|
40
|
+
describe '#authorize_params' do
|
41
|
+
it 'includes display parameter from request when present' do
|
42
|
+
request.stub(:params) { { 'display' => 'touch' } }
|
43
|
+
subject.authorize_params.should be_a(Hash)
|
44
|
+
subject.authorize_params[:display].should eq('touch')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'includes state parameter from request when present' do
|
48
|
+
request.stub(:params) { { 'state' => 'some_state' } }
|
49
|
+
subject.authorize_params.should be_a(Hash)
|
50
|
+
subject.authorize_params[:state].should eq('some_state')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'overrides default scope with parameter passed from request' do
|
54
|
+
request.stub(:params) { { 'scope' => 'email' } }
|
55
|
+
subject.authorize_params.should be_a(Hash)
|
56
|
+
subject.authorize_params[:scope].should eq('email')
|
57
|
+
end
|
58
|
+
end
|
30
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-soundcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth-oauth2
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rspec
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 2.7.0
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.7.0
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rake
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
description:
|
48
63
|
email:
|
49
64
|
- lee@soundcloud.com
|
@@ -76,21 +91,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
91
|
- - ! '>='
|
77
92
|
- !ruby/object:Gem::Version
|
78
93
|
version: '0'
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
hash: 1733435778679222157
|
82
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
95
|
none: false
|
84
96
|
requirements:
|
85
97
|
- - ! '>='
|
86
98
|
- !ruby/object:Gem::Version
|
87
99
|
version: '0'
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
hash: 1733435778679222157
|
91
100
|
requirements: []
|
92
101
|
rubyforge_project:
|
93
|
-
rubygems_version: 1.8.
|
102
|
+
rubygems_version: 1.8.24
|
94
103
|
signing_key:
|
95
104
|
specification_version: 3
|
96
105
|
summary: SoundCloud strategy for OmniAuth
|