omniauth-beats 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e41286f924d0ea88a9dd2e8987b7e04fd62425d8
4
+ data.tar.gz: 987464443e41a93f5c73b9ee167c8d8dc2fc1fd8
5
+ SHA512:
6
+ metadata.gz: d8793624eefa293745d404975a1b1fa630f8f799042660a5d5a92ab49df1a39ba59f75a13e81282a825684d7162c05080932dd12fda1b2c134d278730556569c
7
+ data.tar.gz: 0eb31cd8bc05c45b249d3d5a5f6dfcd4bc9a8361dc0276ba0cf67c1615f84ac5810d7ea0471527e89946211d0752fbbc7f44bcb0b620d10a3af4ce1c95078d36
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .gem
2
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-beats (1.0.0)
5
+ omniauth-oauth2 (~> 1.1.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ faraday (0.9.0)
12
+ multipart-post (>= 1.2, < 3)
13
+ hashie (2.0.5)
14
+ jwt (0.1.11)
15
+ multi_json (>= 1.5)
16
+ multi_json (1.9.2)
17
+ multi_xml (0.5.5)
18
+ multipart-post (2.0.0)
19
+ oauth2 (0.9.3)
20
+ faraday (>= 0.8, < 0.10)
21
+ jwt (~> 0.1.8)
22
+ multi_json (~> 1.3)
23
+ multi_xml (~> 0.5)
24
+ rack (~> 1.2)
25
+ omniauth (1.2.1)
26
+ hashie (>= 1.2, < 3)
27
+ rack (~> 1.0)
28
+ omniauth-oauth2 (1.1.2)
29
+ faraday (>= 0.8, < 0.10)
30
+ multi_json (~> 1.3)
31
+ oauth2 (~> 0.9.3)
32
+ omniauth (~> 1.2)
33
+ rack (1.5.2)
34
+ rake (10.2.2)
35
+ rspec (2.7.0)
36
+ rspec-core (~> 2.7.0)
37
+ rspec-expectations (~> 2.7.0)
38
+ rspec-mocks (~> 2.7.0)
39
+ rspec-core (2.7.1)
40
+ rspec-expectations (2.7.0)
41
+ diff-lcs (~> 1.1.2)
42
+ rspec-mocks (2.7.0)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ omniauth-beats!
49
+ rake
50
+ rspec (~> 2.7.0)
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # OmniAuth Beats
2
+
3
+ An OmniAuth Strategy for Beats Music OAuth2 API
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'omniauth-beats'
11
+ ```
12
+
13
+ Then `bundle install`.
14
+
15
+ ## Basic Usage
16
+
17
+ use OmniAuth::Builder do
18
+ provider "beats", ENV['BEATS_KEY'], ENV['BEATS_SECRET']
19
+ end
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/example/auth.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'sinatra'
2
+ require 'omniauth-beats'
3
+
4
+ use Rack::Session::Cookie
5
+
6
+ use OmniAuth::Builder do
7
+ provider :beats, ENV["BEATS_KEY"], ENV["BEATS_SECRET"]
8
+ end
9
+
10
+ get '/' do
11
+ <<-HTML
12
+ <a href='/auth/beats'>Sign in with Beats Music</a>
13
+ HTML
14
+ end
15
+
16
+ get '/auth/beats/callback' do
17
+ auth = request.env['omniauth.auth']
18
+ redirect '/'
19
+ end
20
+
21
+ get '/auth/failure' do
22
+ puts params[:message]
23
+ redirect '/'
24
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/beats'
@@ -0,0 +1,2 @@
1
+ require 'omniauth/beats/version'
2
+ require 'omniauth/strategies/beats'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Beats
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Beats < OmniAuth::Strategies::OAuth2
6
+ option :name, 'beats'
7
+
8
+ option :client_options, {
9
+ site: 'https://partner.api.beatsmusic.com',
10
+ authorize_url: 'https://partner.api.beatsmusic.com/v1/oauth2/authorize',
11
+ token_url: 'https://partner.api.beatsmusic.com/v1/oauth2/token'
12
+ }
13
+
14
+ uid { user_data['id'] }
15
+
16
+ info do
17
+ {
18
+ name: user_data['full_name'],
19
+ nickname: user_data['username']
20
+ }
21
+ end
22
+
23
+ extra do
24
+ { user_data: user_data }
25
+ end
26
+
27
+ def user_data
28
+ user_id = access_token.get('/v1/api/me').parsed["result"]["user_context"]
29
+ @user_data ||= access_token.get("/v1/api/users/#{ user_id }").parsed["data"]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'omniauth/beats/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'omniauth-beats'
7
+ s.version = OmniAuth::Beats::VERSION
8
+ s.authors = ['Lee Martin']
9
+ s.email = ['hi@leemartin.com']
10
+ s.summary = 'Beats Music strategy for OmniAuth'
11
+ s.description = 'Beats Music strategy for OmniAuth'
12
+ s.homepage = 'https://github.com/leemartin/omniauth-beats'
13
+ s.license = 'MIT'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.1'
21
+
22
+ s.add_development_dependency 'rspec', '~> 2.7.0'
23
+ s.add_development_dependency 'rake'
24
+ end
File without changes
File without changes
File without changes
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-beats
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Lee Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-31 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.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.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.7.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.7.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Beats Music strategy for OmniAuth
56
+ email:
57
+ - hi@leemartin.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - README.md
66
+ - Rakefile
67
+ - example/auth.rb
68
+ - lib/omniauth-beats.rb
69
+ - lib/omniauth/beats.rb
70
+ - lib/omniauth/beats/version.rb
71
+ - lib/omniauth/strategies/beats.rb
72
+ - omniauth-beats.gemspec
73
+ - spec/omniauth/strategies/beats_spec.rb
74
+ - spec/spec_helper.rb
75
+ - spec/support/shared_examples.rb
76
+ homepage: https://github.com/leemartin/omniauth-beats
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.1.5
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Beats Music strategy for OmniAuth
100
+ test_files:
101
+ - spec/omniauth/strategies/beats_spec.rb
102
+ - spec/spec_helper.rb
103
+ - spec/support/shared_examples.rb