omniauth-mixer 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +56 -53
- data/Gemfile +2 -2
- data/Gemfile.lock +41 -41
- data/LICENSE +21 -21
- data/README.md +81 -81
- data/lib/omniauth/mixer.rb +2 -2
- data/lib/omniauth/mixer/version.rb +5 -5
- data/lib/omniauth/strategies/mixer.rb +91 -91
- data/omniauth-mixer.gemspec +24 -24
- data/omniauth-mixer.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f16752be31023718fac8ff4f07663520627485780e5a6f14ac0f8a9cc90bbeb4
|
4
|
+
data.tar.gz: 24ea8993091e70c912d4abc773ad660b7265c5a3a9609ee2040e325f9e8fe94b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa770c48c71f4db14c287a520ff43725f914ef19394940b6afa68cb8b468518893a14bcc17f4a6616b3dc893d74fb8cee19667781a159e3f60cbec7097005218
|
7
|
+
data.tar.gz: '0133578f34918fc62360363a1480a2c5cc909dc3dac59f863948fc7b252b4efe4788adf8cc50a44aa59b66fe4af3d06a58d2ebd7e5ad83c2136ca7af44a66e3b'
|
data/.gitignore
CHANGED
@@ -1,53 +1,56 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
/.config
|
4
|
-
/coverage/
|
5
|
-
/InstalledFiles
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/spec/examples.txt
|
9
|
-
/test/tmp/
|
10
|
-
/test/version_tmp/
|
11
|
-
/tmp/
|
12
|
-
|
13
|
-
# Used by dotenv library to load environment variables.
|
14
|
-
# .env
|
15
|
-
|
16
|
-
## Specific to RubyMotion:
|
17
|
-
.dat*
|
18
|
-
.repl_history
|
19
|
-
build/
|
20
|
-
*.bridgesupport
|
21
|
-
build-iPhoneOS/
|
22
|
-
build-iPhoneSimulator/
|
23
|
-
|
24
|
-
## Specific to RubyMotion (use of CocoaPods):
|
25
|
-
#
|
26
|
-
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
-
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
-
#
|
30
|
-
# vendor/Pods/
|
31
|
-
|
32
|
-
## Documentation cache and generated files:
|
33
|
-
/.yardoc/
|
34
|
-
/_yardoc/
|
35
|
-
/doc/
|
36
|
-
/rdoc/
|
37
|
-
|
38
|
-
## Environment normalization:
|
39
|
-
/.bundle/
|
40
|
-
/vendor/bundle
|
41
|
-
/lib/bundler/man/
|
42
|
-
|
43
|
-
# for a library or gem, you might want to ignore these files since the code is
|
44
|
-
# intended to run in multiple environments; otherwise, check them in:
|
45
|
-
# Gemfile.lock
|
46
|
-
# .ruby-version
|
47
|
-
# .ruby-gemset
|
48
|
-
|
49
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
-
.rvmrc
|
51
|
-
|
52
|
-
## Visual Studio Code
|
53
|
-
.vscode
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
|
52
|
+
## Visual Studio Code
|
53
|
+
.vscode
|
54
|
+
|
55
|
+
## RubyMine files
|
56
|
+
/.idea/
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
omniauth-mixer (0.1.
|
5
|
-
omniauth-oauth2 (~> 1.
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
faraday (0.
|
11
|
-
multipart-post (>= 1.2, < 3)
|
12
|
-
hashie (3.
|
13
|
-
jwt (
|
14
|
-
multi_json (1.
|
15
|
-
multi_xml (0.6.0)
|
16
|
-
multipart-post (2.
|
17
|
-
oauth2 (1.4.
|
18
|
-
faraday (>= 0.8, < 0.
|
19
|
-
jwt (
|
20
|
-
multi_json (~> 1.3)
|
21
|
-
multi_xml (~> 0.5)
|
22
|
-
rack (>= 1.2, < 3)
|
23
|
-
omniauth (1.
|
24
|
-
hashie (>= 3.4.6, < 3.
|
25
|
-
rack (>= 1.6.2, < 3)
|
26
|
-
omniauth-oauth2 (1.
|
27
|
-
oauth2 (~> 1.
|
28
|
-
omniauth (~> 1.
|
29
|
-
rack (2.0.
|
30
|
-
rake (0.9.6)
|
31
|
-
|
32
|
-
PLATFORMS
|
33
|
-
ruby
|
34
|
-
|
35
|
-
DEPENDENCIES
|
36
|
-
bundler (~> 1.5)
|
37
|
-
omniauth-mixer!
|
38
|
-
rake (~> 0)
|
39
|
-
|
40
|
-
BUNDLED WITH
|
41
|
-
1.
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-mixer (0.1.1)
|
5
|
+
omniauth-oauth2 (~> 1.6)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
faraday (0.15.4)
|
11
|
+
multipart-post (>= 1.2, < 3)
|
12
|
+
hashie (3.6.0)
|
13
|
+
jwt (2.2.1)
|
14
|
+
multi_json (1.13.1)
|
15
|
+
multi_xml (0.6.0)
|
16
|
+
multipart-post (2.1.1)
|
17
|
+
oauth2 (1.4.1)
|
18
|
+
faraday (>= 0.8, < 0.16.0)
|
19
|
+
jwt (>= 1.0, < 3.0)
|
20
|
+
multi_json (~> 1.3)
|
21
|
+
multi_xml (~> 0.5)
|
22
|
+
rack (>= 1.2, < 3)
|
23
|
+
omniauth (1.9.0)
|
24
|
+
hashie (>= 3.4.6, < 3.7.0)
|
25
|
+
rack (>= 1.6.2, < 3)
|
26
|
+
omniauth-oauth2 (1.6.0)
|
27
|
+
oauth2 (~> 1.1)
|
28
|
+
omniauth (~> 1.9)
|
29
|
+
rack (2.0.7)
|
30
|
+
rake (0.9.6)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
bundler (~> 1.5)
|
37
|
+
omniauth-mixer!
|
38
|
+
rake (~> 0)
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
1.17.1
|
data/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2016 csauls
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 csauls
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,81 +1,81 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/omniauth-mixer.svg)](https://badge.fury.io/rb/omniauth-mixer)
|
2
|
-
|
3
|
-
# OmniAuth::Mixer
|
4
|
-
OmniAuth strategy for Mixer
|
5
|
-
|
6
|
-
## Installation
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'omniauth-mixer'
|
10
|
-
|
11
|
-
Then run `bundle install`
|
12
|
-
|
13
|
-
Or install it yourself with `gem install omniauth-mixer`
|
14
|
-
|
15
|
-
### Using Directly
|
16
|
-
```ruby
|
17
|
-
Rails.application.config.middleware.use OmniAuth::Builder do
|
18
|
-
provider :mixer, ENV['MIXER_CLIENT_ID'], ENV['MIXER_CLIENT_SECRET']
|
19
|
-
end
|
20
|
-
```
|
21
|
-
|
22
|
-
### Using With Devise
|
23
|
-
Add to `config/initializers/devise.rb`
|
24
|
-
```ruby
|
25
|
-
config.omniauth :mixer, ENV['MIXER_CLIENT_ID'], ENV['MIXER_CLIENT_SECRET']
|
26
|
-
```
|
27
|
-
|
28
|
-
And apply it to your Devise user model:
|
29
|
-
```ruby
|
30
|
-
class User < ApplicationRecord
|
31
|
-
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
|
32
|
-
:trackable, :validatable, :omniauthable,
|
33
|
-
omniauth_providers: %i(mixer)
|
34
|
-
|
35
|
-
def self.from_omniauth(auth)
|
36
|
-
user = where(provider: auth.provider, uid: auth.uid).first_or_create do |u|
|
37
|
-
u.password = Devise.friendly_token[0, 20]
|
38
|
-
u.provider = auth.provider
|
39
|
-
u.uid = auth.uid
|
40
|
-
end
|
41
|
-
user.update avatar_url: auth.info.image,
|
42
|
-
email: auth.info.email,
|
43
|
-
name: auth.info.name
|
44
|
-
user
|
45
|
-
end
|
46
|
-
end
|
47
|
-
```
|
48
|
-
|
49
|
-
## Default Scope
|
50
|
-
|
51
|
-
The default scope is set to _user:details:self_, making this hash available in `request.env['omniauth.auth']`:
|
52
|
-
```ruby
|
53
|
-
{
|
54
|
-
provider: 'mixer',
|
55
|
-
uid: 123456789,
|
56
|
-
info: {
|
57
|
-
name: 'JohnDoe',
|
58
|
-
email: 'johndoe@example.com',
|
59
|
-
description: 'My channel.',
|
60
|
-
image: 'https://uploads.mixer.com/avatar/12345678-1234.jpg',
|
61
|
-
social: {
|
62
|
-
discord: 'johndoe#12345',
|
63
|
-
facebook: 'https://facebook.com/John.Doe'
|
64
|
-
player: 'https://player.me/johndoe',
|
65
|
-
twitter: 'https://twitter.com/johndoe',
|
66
|
-
youtube: 'https://youtube.com/user/johndoe'
|
67
|
-
},
|
68
|
-
urls: { Mixer: 'https://mixer.com/johndoe' }
|
69
|
-
},
|
70
|
-
credentials: {
|
71
|
-
token: 'asdfghjklasdfghjklasdfghjkl',
|
72
|
-
refresh_token: 'qwertyuiopqwertyuiopqwertyuiop',
|
73
|
-
expires_at: 1477577799,
|
74
|
-
expires: true
|
75
|
-
}
|
76
|
-
}
|
77
|
-
```
|
78
|
-
|
79
|
-
## Credits
|
80
|
-
|
81
|
-
Derived from omniauth-beam: https://github.com/charmquark/omniauth-beam
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/omniauth-mixer.svg)](https://badge.fury.io/rb/omniauth-mixer)
|
2
|
+
|
3
|
+
# OmniAuth::Mixer
|
4
|
+
OmniAuth strategy for Mixer
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'omniauth-mixer'
|
10
|
+
|
11
|
+
Then run `bundle install`
|
12
|
+
|
13
|
+
Or install it yourself with `gem install omniauth-mixer`
|
14
|
+
|
15
|
+
### Using Directly
|
16
|
+
```ruby
|
17
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
18
|
+
provider :mixer, ENV['MIXER_CLIENT_ID'], ENV['MIXER_CLIENT_SECRET']
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
### Using With Devise
|
23
|
+
Add to `config/initializers/devise.rb`
|
24
|
+
```ruby
|
25
|
+
config.omniauth :mixer, ENV['MIXER_CLIENT_ID'], ENV['MIXER_CLIENT_SECRET']
|
26
|
+
```
|
27
|
+
|
28
|
+
And apply it to your Devise user model:
|
29
|
+
```ruby
|
30
|
+
class User < ApplicationRecord
|
31
|
+
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
|
32
|
+
:trackable, :validatable, :omniauthable,
|
33
|
+
omniauth_providers: %i(mixer)
|
34
|
+
|
35
|
+
def self.from_omniauth(auth)
|
36
|
+
user = where(provider: auth.provider, uid: auth.uid).first_or_create do |u|
|
37
|
+
u.password = Devise.friendly_token[0, 20]
|
38
|
+
u.provider = auth.provider
|
39
|
+
u.uid = auth.uid
|
40
|
+
end
|
41
|
+
user.update avatar_url: auth.info.image,
|
42
|
+
email: auth.info.email,
|
43
|
+
name: auth.info.name
|
44
|
+
user
|
45
|
+
end
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
## Default Scope
|
50
|
+
|
51
|
+
The default scope is set to _user:details:self_, making this hash available in `request.env['omniauth.auth']`:
|
52
|
+
```ruby
|
53
|
+
{
|
54
|
+
provider: 'mixer',
|
55
|
+
uid: 123456789,
|
56
|
+
info: {
|
57
|
+
name: 'JohnDoe',
|
58
|
+
email: 'johndoe@example.com',
|
59
|
+
description: 'My channel.',
|
60
|
+
image: 'https://uploads.mixer.com/avatar/12345678-1234.jpg',
|
61
|
+
social: {
|
62
|
+
discord: 'johndoe#12345',
|
63
|
+
facebook: 'https://facebook.com/John.Doe'
|
64
|
+
player: 'https://player.me/johndoe',
|
65
|
+
twitter: 'https://twitter.com/johndoe',
|
66
|
+
youtube: 'https://youtube.com/user/johndoe'
|
67
|
+
},
|
68
|
+
urls: { Mixer: 'https://mixer.com/johndoe' }
|
69
|
+
},
|
70
|
+
credentials: {
|
71
|
+
token: 'asdfghjklasdfghjklasdfghjkl',
|
72
|
+
refresh_token: 'qwertyuiopqwertyuiopqwertyuiop',
|
73
|
+
expires_at: 1477577799,
|
74
|
+
expires: true
|
75
|
+
}
|
76
|
+
}
|
77
|
+
```
|
78
|
+
|
79
|
+
## Credits
|
80
|
+
|
81
|
+
Derived from omniauth-beam: https://github.com/charmquark/omniauth-beam
|
data/lib/omniauth/mixer.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'omniauth/mixer/version'
|
2
|
-
require 'omniauth/strategies/mixer'
|
1
|
+
require 'omniauth/mixer/version'
|
2
|
+
require 'omniauth/strategies/mixer'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module OmniAuth
|
2
|
-
module Mixer
|
3
|
-
VERSION = '0.1.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module OmniAuth
|
2
|
+
module Mixer
|
3
|
+
VERSION = '0.1.1'.freeze
|
4
|
+
end
|
5
|
+
end
|
@@ -1,91 +1,91 @@
|
|
1
|
-
require 'omniauth-oauth2'
|
2
|
-
|
3
|
-
module OmniAuth
|
4
|
-
module Strategies
|
5
|
-
#
|
6
|
-
class Mixer < OmniAuth::Strategies::OAuth2
|
7
|
-
BLANK_PARAMS = [nil, ''].freeze
|
8
|
-
DEFAULT_SCOPE = 'user:details:self'.freeze
|
9
|
-
RAW_INFO_URL = '/api/v1/users/current'.freeze
|
10
|
-
SOCIAL_KEYS = %w(facebook discord player twitter youtube).freeze
|
11
|
-
|
12
|
-
option :name, 'mixer'
|
13
|
-
|
14
|
-
option :client_options,
|
15
|
-
site: 'https://mixer.com',
|
16
|
-
authorize_url: '/oauth/authorize',
|
17
|
-
token_url: '/api/v1/oauth/token'
|
18
|
-
|
19
|
-
option :access_token_options,
|
20
|
-
header_format: 'OAuth %s',
|
21
|
-
param_name: 'access_token'
|
22
|
-
|
23
|
-
option :authorize_options, [:scope]
|
24
|
-
|
25
|
-
uid { raw_info['id'] }
|
26
|
-
|
27
|
-
info do
|
28
|
-
{
|
29
|
-
name: raw_info['username'],
|
30
|
-
email: raw_info['email'],
|
31
|
-
description: raw_info['bio'],
|
32
|
-
image: raw_info['avatarUrl'],
|
33
|
-
social: social_info,
|
34
|
-
urls: urls_info
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
extra do
|
39
|
-
{
|
40
|
-
raw_info: raw_info
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
def access_token_options
|
45
|
-
options.access_token_options.each_with_object({}) do |(key, val), hsh|
|
46
|
-
hsh[key.to_sym] = val
|
47
|
-
hsh
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def authorize_params
|
52
|
-
super.tap do |params|
|
53
|
-
options[:authorize_options].each do |key|
|
54
|
-
val = request.params[key.to_s]
|
55
|
-
params[key] = val unless BLANK_PARAMS.include? val
|
56
|
-
end
|
57
|
-
params[:scope] ||= DEFAULT_SCOPE
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def build_access_token
|
62
|
-
super.tap do |token|
|
63
|
-
token.options.merge! access_token_options
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def callback_url
|
68
|
-
return options[:redirect_url] if options.key? :redirect_url
|
69
|
-
full_host + script_name + callback_path
|
70
|
-
end
|
71
|
-
|
72
|
-
def raw_info
|
73
|
-
@raw_info ||= access_token.get(RAW_INFO_URL).parsed
|
74
|
-
end
|
75
|
-
|
76
|
-
def social_info
|
77
|
-
raw_social = raw_info['social']
|
78
|
-
SOCIAL_KEYS.each_with_object({}) do |key, hsh|
|
79
|
-
hsh[key.to_sym] = raw_social[key] if raw_social.key? key
|
80
|
-
hsh
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def urls_info
|
85
|
-
{
|
86
|
-
Mixer: "http://mixer.com/#{raw_info['channel']['token']}"
|
87
|
-
}
|
88
|
-
end
|
89
|
-
end # Mixer
|
90
|
-
end # Strategies
|
91
|
-
end # OmniAuth
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
#
|
6
|
+
class Mixer < OmniAuth::Strategies::OAuth2
|
7
|
+
BLANK_PARAMS = [nil, ''].freeze
|
8
|
+
DEFAULT_SCOPE = 'user:details:self'.freeze
|
9
|
+
RAW_INFO_URL = '/api/v1/users/current'.freeze
|
10
|
+
SOCIAL_KEYS = %w(facebook discord player twitter youtube).freeze
|
11
|
+
|
12
|
+
option :name, 'mixer'
|
13
|
+
|
14
|
+
option :client_options,
|
15
|
+
site: 'https://mixer.com',
|
16
|
+
authorize_url: '/oauth/authorize',
|
17
|
+
token_url: '/api/v1/oauth/token'
|
18
|
+
|
19
|
+
option :access_token_options,
|
20
|
+
header_format: 'OAuth %s',
|
21
|
+
param_name: 'access_token'
|
22
|
+
|
23
|
+
option :authorize_options, [:scope]
|
24
|
+
|
25
|
+
uid { raw_info['id'] }
|
26
|
+
|
27
|
+
info do
|
28
|
+
{
|
29
|
+
name: raw_info['username'],
|
30
|
+
email: raw_info['email'],
|
31
|
+
description: raw_info['bio'],
|
32
|
+
image: raw_info['avatarUrl'],
|
33
|
+
social: social_info,
|
34
|
+
urls: urls_info
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
extra do
|
39
|
+
{
|
40
|
+
raw_info: raw_info
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def access_token_options
|
45
|
+
options.access_token_options.each_with_object({}) do |(key, val), hsh|
|
46
|
+
hsh[key.to_sym] = val
|
47
|
+
hsh
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def authorize_params
|
52
|
+
super.tap do |params|
|
53
|
+
options[:authorize_options].each do |key|
|
54
|
+
val = request.params[key.to_s]
|
55
|
+
params[key] = val unless BLANK_PARAMS.include? val
|
56
|
+
end
|
57
|
+
params[:scope] ||= DEFAULT_SCOPE
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def build_access_token
|
62
|
+
super.tap do |token|
|
63
|
+
token.options.merge! access_token_options
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def callback_url
|
68
|
+
return options[:redirect_url] if options.key? :redirect_url
|
69
|
+
full_host + script_name + callback_path
|
70
|
+
end
|
71
|
+
|
72
|
+
def raw_info
|
73
|
+
@raw_info ||= access_token.get(RAW_INFO_URL).parsed
|
74
|
+
end
|
75
|
+
|
76
|
+
def social_info
|
77
|
+
raw_social = raw_info['social']
|
78
|
+
SOCIAL_KEYS.each_with_object({}) do |key, hsh|
|
79
|
+
hsh[key.to_sym] = raw_social[key] if raw_social.key? key
|
80
|
+
hsh
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def urls_info
|
85
|
+
{
|
86
|
+
Mixer: "http://mixer.com/#{raw_info['channel']['token']}"
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end # Mixer
|
90
|
+
end # Strategies
|
91
|
+
end # OmniAuth
|
data/omniauth-mixer.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'omniauth/mixer/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'omniauth-mixer'
|
8
|
-
spec.version = OmniAuth::Mixer::VERSION
|
9
|
-
spec.authors = ['Dave Hartnoll "KeyMailer"']
|
10
|
-
spec.email = ['
|
11
|
-
spec.summary = 'Mixer OAuth2 Strategy for OmniAuth'
|
12
|
-
spec.homepage = 'https://github.com/KeyMailer/omniauth-mixer'
|
13
|
-
spec.license = 'MIT'
|
14
|
-
|
15
|
-
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = ['lib']
|
19
|
-
|
20
|
-
spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.
|
21
|
-
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
-
spec.add_development_dependency 'rake', '~> 0'
|
24
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/mixer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'omniauth-mixer'
|
8
|
+
spec.version = OmniAuth::Mixer::VERSION
|
9
|
+
spec.authors = ['Dave Hartnoll "KeyMailer"','Jim Grimmett "KeyMailer"']
|
10
|
+
spec.email = ['jim.grimmett@keymailer.co']
|
11
|
+
spec.summary = 'Mixer OAuth2 Strategy for OmniAuth'
|
12
|
+
spec.homepage = 'https://github.com/KeyMailer/omniauth-mixer'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.6'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
+
spec.add_development_dependency 'rake', '~> 0'
|
24
|
+
end
|
data/omniauth-mixer.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'omniauth/mixer'
|
1
|
+
require 'omniauth/mixer'
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-mixer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Hartnoll "KeyMailer"
|
8
|
+
- Jim Grimmett "KeyMailer"
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2019-05-30 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: omniauth-oauth2
|
@@ -16,14 +17,14 @@ dependencies:
|
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
20
|
+
version: '1.6'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
27
|
+
version: '1.6'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: bundler
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,7 +55,7 @@ dependencies:
|
|
54
55
|
version: '0'
|
55
56
|
description:
|
56
57
|
email:
|
57
|
-
-
|
58
|
+
- jim.grimmett@keymailer.co
|
58
59
|
executables: []
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
@@ -88,10 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '0'
|
90
91
|
requirements: []
|
91
|
-
|
92
|
-
rubygems_version: 2.5.1
|
92
|
+
rubygems_version: 3.0.3
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: Mixer OAuth2 Strategy for OmniAuth
|
96
96
|
test_files: []
|
97
|
-
has_rdoc:
|