omniauth-rdio 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +101 -0
- data/Rakefile +2 -0
- data/lib/omniauth-rdio.rb +1 -0
- data/lib/omniauth/strategies/rdio.rb +54 -0
- data/omniauth-rdio.gemspec +20 -0
- metadata +65 -0
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Gopal Patel
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
OmniAuth Rdio
|
2
|
+
=============
|
3
|
+
|
4
|
+
[Rdio OAuth 1.0a][rdio-oauth] Strategy for OmniAuth 1.0.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add to your project Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'omniauth-rdio'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Read the [OmniAuth 1.0][omniauth] documentation for detailed instructions.
|
17
|
+
|
18
|
+
Pass your [Rdio Application Key and Secret][rdio-register] as arguments when
|
19
|
+
initializing the provider.
|
20
|
+
|
21
|
+
For example, if using as middleware in a Rails app, add the following to an
|
22
|
+
initializer:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
26
|
+
provider :rdio, ENV['RDIO_APP_KEY'], ENV['RDIO_APP_SECRET']
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
## Authentication Hash
|
31
|
+
|
32
|
+
Example of the provider's [Auth Hash Schema][hash-schema]
|
33
|
+
(`request.env['omniauth.auth']`):
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
{
|
37
|
+
"provider" => "rdio",
|
38
|
+
"uid" => "aaa...",
|
39
|
+
"info" => {
|
40
|
+
"name" => "Gopal Patel",
|
41
|
+
"nickname" => "nixme",
|
42
|
+
"first_name" => "Gopal",
|
43
|
+
"last_name" => "Patel",
|
44
|
+
"image" => "http://cdn3.rd.io/user/no-user-image-square.jpg",
|
45
|
+
"urls" => {
|
46
|
+
"User" => "http://www.rdio.com/people/nixme/",
|
47
|
+
"Collection" => "http://www.rdio.com/people/nixme/collection/",
|
48
|
+
"Playlists" => "http://www.rdio.com/people/nixme/playlists/",
|
49
|
+
"Following" => "http://www.rdio.com/people/nixme/people/following/",
|
50
|
+
"Followers" => "http://www.rdio.com/people/nixme/people/followers/"
|
51
|
+
}
|
52
|
+
},
|
53
|
+
"credentials" => {
|
54
|
+
"token" => "123456...", # OAuth access token
|
55
|
+
"secret" => "abcde..." # OAuth secret
|
56
|
+
},
|
57
|
+
"extra" => {
|
58
|
+
"access_token" => <OAuth::AccessToken>, # OAuth::AccessToken instance for making API requests.
|
59
|
+
"raw_info" => { # Result of the currentUser Rdio Web Service call.
|
60
|
+
"followingUrl" => "/people/nixme/people/following/", # Includes all optional User fields
|
61
|
+
"baseIcon" => "user/no-user-image-square.jpg", # except lastSongPlayed and
|
62
|
+
"isTrial" => false, # lastSongPlayTime.
|
63
|
+
"artistCount" => 64,
|
64
|
+
"heavyRotationKey" => "eee...",
|
65
|
+
"networkHeavyRotationKey" => "bbb...",
|
66
|
+
"albumCount" => 114,
|
67
|
+
"libraryVersion" => 406,
|
68
|
+
"trackCount" => 1391,
|
69
|
+
"type" => "s",
|
70
|
+
"username" => "nixme",
|
71
|
+
"collectionUrl" => "/people/nixme/collection/",
|
72
|
+
"playlistsUrl" => "/people/nixme/playlists/",
|
73
|
+
"key" => "aaa...",
|
74
|
+
"collectionKey" => "ccc...",
|
75
|
+
"followersUrl" => "/people/nixme/people/followers/",
|
76
|
+
"icon" => "http://cdn3.rd.io/user/no-user-image-square.jpg",
|
77
|
+
"displayName" => "Gopal Patel",
|
78
|
+
"isUnlimited" => true,
|
79
|
+
"firstName" => "Gopal",
|
80
|
+
"url" => "/people/nixme/",
|
81
|
+
"gender" => "m",
|
82
|
+
"lastName" => "Patel",
|
83
|
+
"isSubscriber" => true
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
```
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
|
91
|
+
Patches and bug reports are welcome. Just send a [pull request][pullrequests] or
|
92
|
+
file an [issue][issues]. [Project changelog][changelog].
|
93
|
+
|
94
|
+
|
95
|
+
[rdio-oauth]: http://developer.rdio.com/docs/read/rest/oauth
|
96
|
+
[omniauth]: https://github.com/intridea/omniauth
|
97
|
+
[rdio-register]: http://developer.rdio.com/apps/register
|
98
|
+
[hash-schema]: https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema
|
99
|
+
[pullrequests]: https://github.com/nixme/omniauth-rdio/pulls
|
100
|
+
[issues]: https://github.com/nixme/omniauth-rdio/issues
|
101
|
+
[changelog]: https://github.com/nixme/omniauth-rdio/blob/master/CHANGELOG.md
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/strategies/rdio'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'omniauth-oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
class OmniAuth::Strategies::Rdio < OmniAuth::Strategies::OAuth
|
5
|
+
option :name, 'rdio'
|
6
|
+
option :client_options, {
|
7
|
+
:site => 'http://api.rdio.com',
|
8
|
+
:authorize_url => 'https://www.rdio.com/oauth/authorize'
|
9
|
+
}
|
10
|
+
|
11
|
+
uid { raw_info['key'] }
|
12
|
+
|
13
|
+
BASE_URL = 'http://www.rdio.com'
|
14
|
+
|
15
|
+
info do
|
16
|
+
{
|
17
|
+
:name => "#{raw_info['firstName']} #{raw_info['lastName']}".strip,
|
18
|
+
:nickname => raw_info['username'],
|
19
|
+
:first_name => raw_info['firstName'],
|
20
|
+
:last_name => raw_info['lastName'],
|
21
|
+
:image => raw_info['icon'],
|
22
|
+
:urls => {
|
23
|
+
'User' => BASE_URL + raw_info['url'],
|
24
|
+
'Collection' => BASE_URL + raw_info['collectionUrl'],
|
25
|
+
'Playlists' => BASE_URL + raw_info['playlistsUrl'],
|
26
|
+
'Following' => BASE_URL + raw_info['followingUrl'],
|
27
|
+
'Followers' => BASE_URL + raw_info['followersUrl']
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
extra do
|
33
|
+
{ 'raw_info' => raw_info }
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
# All optional User fields except lastSongPlayed and lastSongPlayTime.
|
38
|
+
# See http://developer.rdio.com/docs/read/rest/types#User
|
39
|
+
EXTRA_USER_FIELDS = 'followingUrl,isTrial,artistCount,heavyRotationKey,networkHeavyRotationKey,albumCount,trackCount,username,collectionUrl,playlistsUrl,collectionKey,followersUrl,displayName,isUnlimited,isSubscriber'
|
40
|
+
|
41
|
+
# Rdio User object from the currentUser call
|
42
|
+
# See http://developer.rdio.com/docs/read/rest/Methods#currentUser
|
43
|
+
def raw_info
|
44
|
+
@raw_info ||=
|
45
|
+
begin
|
46
|
+
json = access_token.post('http://api.rdio.com/1/',
|
47
|
+
:method => 'currentUser',
|
48
|
+
:extras => EXTRA_USER_FIELDS).body
|
49
|
+
MultiJson.decode(json)['result']
|
50
|
+
end
|
51
|
+
rescue ::Errno::ETIMEDOUT
|
52
|
+
raise ::Timeout::Error
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'omniauth-rdio'
|
5
|
+
gem.version = '0.1.0'
|
6
|
+
gem.author = 'Gopal Patel'
|
7
|
+
gem.email = 'nixme@stillhope.com'
|
8
|
+
gem.license = 'MIT'
|
9
|
+
gem.homepage = 'https://github.com/nixme/omniauth-rdio'
|
10
|
+
gem.summary = 'OmniAuth strategy for Rdio'
|
11
|
+
gem.description = 'OmniAuth strategy for Rdio'
|
12
|
+
|
13
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
# Dependencies
|
19
|
+
gem.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-rdio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gopal Patel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth
|
16
|
+
requirement: &70116230462560 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70116230462560
|
25
|
+
description: OmniAuth strategy for Rdio
|
26
|
+
email: nixme@stillhope.com
|
27
|
+
executables: []
|
28
|
+
extensions: []
|
29
|
+
extra_rdoc_files: []
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- CHANGELOG.md
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- lib/omniauth-rdio.rb
|
38
|
+
- lib/omniauth/strategies/rdio.rb
|
39
|
+
- omniauth-rdio.gemspec
|
40
|
+
homepage: https://github.com/nixme/omniauth-rdio
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.8.11
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: OmniAuth strategy for Rdio
|
65
|
+
test_files: []
|