omniauth-rhapsody 0.1.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9da4ea2055c7aecf77a97f6c1a7b7c691c51a94
4
+ data.tar.gz: 683d2bd8f1ffa61aeb83728e64432acdfeb4ad15
5
+ SHA512:
6
+ metadata.gz: 667c0c021778b5abdb41a84d2f3de79740383ef7ae26d44819974b2ec418e0e3ca940f61219ef0b8ae0c14271b32a40bbf107a5c481fc5c0b1f630161305cbdd
7
+ data.tar.gz: 96b4efb36c44d1585d4dc14c9073202a37cbe7655f96d8b533e9adcba280f8e6c37385a5ca5eb59eab6e23ef7b698272bf5044c1990d4b71bd670b2de8480a76
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-box2.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Matt Fitz-Henry
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,123 @@
1
+ # Rhapsody Music OmniAuth Strategy
2
+
3
+ This gem provides a simple way to authenticate to Rhapsody Web API using OmniAuth with OAuth2.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-rhapsody'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-rhapsody
18
+
19
+ ## Usage
20
+
21
+ You'll need to register an app on rhapsody, you can do this here - https://developer.rhapsody.com/api#
22
+
23
+ Usage of the gem is very similar to other OmniAuth strategies.
24
+ You'll need to add your app credentials to `config/initializers/omniauth.rb`:
25
+
26
+ ```ruby
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :rhapsody, 'app_id', 'app_secret', scope: 'playlist-read-private user-read-private user-read-email'
29
+ end
30
+ ```
31
+
32
+ Please replace the example `scope` provided with your own.
33
+ Read more about scopes here: https://developer.rhapsody.com/web-api/using-scopes/
34
+
35
+ Or with Devise in `config/initializers/devise.rb`:
36
+
37
+ ```ruby
38
+ config.omniauth :rhapsody, 'app_id', 'app_secret', scope: 'playlist-read-private user-read-private user-read-email'
39
+ ```
40
+
41
+ ## Auth Hash Schema
42
+
43
+ Here's an example auth hash, available in `request.env['omniauth.auth']`:
44
+ ```
45
+ { "provider":"rhapsody",
46
+ "uid":"A155SDLKJLKSFJLKJLSKJD30A96033200CA",
47
+ "info":
48
+ {"uid":"A15KSJLKJSLDKJE0430A96033200CA", "name":nil, "email":nil},
49
+ "credentials":
50
+ {"token":"OLKSJDkjsfojasLKJsfjksdlkjZmM0LThiOTgtYzg5MThlZThiZGNj",
51
+ "refresh_token":"3sdk34c97-1ce5-443455-8999-e5aasdlkj7f72",
52
+ "expires_at":1463103543,
53
+ "expires":true},
54
+ "extra":
55
+ {"raw_info":
56
+ {"me":
57
+ {"id":"A1KJSDKJLKJFHJSDLKJFA96033200CA",
58
+ "realName":"Matt Fitz-Henry",
59
+ "screenName":"mfitzhenry",
60
+ "gender":"male",
61
+ "visibility":"private",
62
+ "type":"member",
63
+ "href":
64
+ "http://api.rhapsody.com/members/A23498983409584098098457CA",
65
+ "favoriteAlbumsCount":0,
66
+ "favoriteArtistsCount":0,
67
+ "favoriteTracksCount":0,
68
+ "playlistsTotalCount":0,
69
+ "playlistsTotalCount":0,
70
+ "info":
71
+ {"uid":"A15IFUNSYFLSKE0430A96033200CA", "name":nil, "email":nil},
72
+ "credentials":asdkljlafkjJHSJDHKJjskndViYzgtNmI4Ny00ZmM0LasdlkjqweiuLAULkrl",
73
+ "refresh_token":"334f8c97-1ce7-4434-8999-easdasdljkjsd72",
74
+ "expires_at":1463103543,
75
+ "expires":true},
76
+ "extra":
77
+ {"raw_info":
78
+ {"me":
79
+ {"id":"A155547F650900CAE0430A96033200CA",
80
+ "realName":"Matt Fitz-Henry",
81
+ "screenName":"mfitzhenry",
82
+ "gender":"male",
83
+ "visibility":"private",
84
+ "type":"member",
85
+ "href":
86
+ "http://api.rhapsody.com/members/A155547F650900CAE048723409812389200CA",
87
+ "favoriteAlbumsCount":0,
88
+ "favoriteArtistsCount":0,
89
+ "favoriteTracksCount":0,
90
+ "playlistsTotalCount":0,
91
+ "playlistsPublishedCount":0,
92
+ "stationsCount":0,
93
+ "radioCount":0,
94
+ "followingCount":0,
95
+ "followerCount":0,
96
+ "avatar":
97
+ "http://direct.rhapsody.com/imageserver/v2/external/aHR0cHM6Ly9yaGFwc29keS1uYXBpLnMzLmFtYXpvbmF3cy5jb20vbWVtYmVyLzAwMDAwMF9kZWZhdWx0L2F2YXRhci9vcmlnaW5hbF8w/images/108x108.jpg",
98
+ "avatarId":
99
+ "aHR0cHM6Ly9yaGFwc29keS1uYXBpLnMzLmFtYXpvbmF3cy5jb20vbWVtYmVyLzAwMDAwMF9kZWZhdWx0L2F2YXRhci9vcmlnaW5hbF8w",
100
+ "defaultAvatar":"true",
101
+ "avatarVersion":1,
102
+ "links":
103
+ }
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
109
+ ```ruby
110
+ *** To Be Added ***
111
+
112
+ ## More
113
+
114
+ This gem is brought to you by the [Genome](https://geno.me) team.
115
+ Enjoy!
116
+
117
+ ## Contributing
118
+
119
+ 1. Fork it
120
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
121
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
122
+ 4. Push to the branch (`git push origin my-new-feature`)
123
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-rhapsody/version"
2
+ require "omniauth/strategies/rhapsody"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Rhapsody
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Rhapsody < OmniAuth::Strategies::OAuth2
6
+ include OmniAuth::Strategy
7
+ # Give your strategy a name.
8
+ option :name, 'rhapsody'
9
+
10
+ # This is where you pass the options you would pass when
11
+ # initializing your consumer from the OAuth gem.
12
+ option :client_options, {
13
+ :site => 'https://api.rhapsody.com/v1',
14
+ :authorize_url => 'https://api.rhapsody.com/oauth/authorize',
15
+ :token_url => 'https://api.rhapsody.com/oauth/access_token',
16
+ }
17
+
18
+ uid{ raw_info['me']['id'] }
19
+
20
+ info do
21
+ {
22
+ :uid => raw_info['me']['id'],
23
+ :name => raw_info['me']['realName'],
24
+ :username => raw_info['me']['screenName'],
25
+ :image => raw_info['me']['avatar']
26
+ }
27
+ end
28
+
29
+ # These are called after authentication has succeeded. If
30
+ # possible, you should try to set the UID without making
31
+ # additional calls (if the user id is returned with the token
32
+ # or as a URI parameter). This may not be possible with all
33
+ # providers.
34
+
35
+ extra do
36
+ {
37
+ 'raw_info' => raw_info
38
+ }
39
+ end
40
+
41
+ def raw_info
42
+ @raw_info ||= access_token.get('/me').parsed
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-rhapsody/version'
5
+ require 'omniauth/strategies/rhapsody'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = "omniauth-rhapsody"
9
+ gem.version = Omniauth::Rhapsody::VERSION
10
+ gem.authors = ["Matt Fitz-Henry"]
11
+ gem.email = ["matt@geno.me\n"]
12
+ gem.description = %q{OmniAuth strategy for Rhapsody Music Service}
13
+ gem.summary = %q{OmniAuth strategy for Rhapsody Music Service}
14
+ gem.homepage = "https://github.com/GenomeUS/omniauth-rhapsody.git"
15
+ gem.required_ruby_version = '~> 2.0'
16
+ gem.licenses = ['MIT']
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+ gem.post_install_message = "Thanks for installing! If you have any questions, or contributions feel free to reach out contact@geno.me"
22
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
23
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-rhapsody
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Matt Fitz-Henry
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ description: OmniAuth strategy for Rhapsody Music Service
28
+ email:
29
+ - 'matt@geno.me
30
+
31
+ '
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".gitignore"
37
+ - Gemfile
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - lib/omniauth-rhapsody.rb
42
+ - lib/omniauth-rhapsody/version.rb
43
+ - lib/omniauth/strategies/rhapsody.rb
44
+ - omniauth-rhapsody.gemspec
45
+ homepage: https://github.com/GenomeUS/omniauth-rhapsody.git
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message: Thanks for installing! If you have any questions, or contributions
50
+ feel free to reach out contact@geno.me
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: '2.0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.5.1
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: OmniAuth strategy for Rhapsody Music Service
70
+ test_files: []