omniauth-streamlabs 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9de0c3cd9c78888fb467eed7ae107df116d1fbeb
4
- data.tar.gz: b108b98460167d87e8ecc97513b197b7fe6b0026
3
+ metadata.gz: efc3e2d0ab4e64c225d4f77ed8432331e35b5b79
4
+ data.tar.gz: a1c53c61be87b9db4e23710e989a2f6f02dc4375
5
5
  SHA512:
6
- metadata.gz: f1f02806aefe10645257e3bc8d096bb9580cf92e6e445c5624c6a70519a371ae0cd8b9304fba3c7d8d5101d5f5361f60c43ad07c11161e9239d3f0f1b501068c
7
- data.tar.gz: dd94040b55750cea28e078480469438fb9f174d33f3d9e608f9fb11cee1a3b3a29f51d0d0ca2d907b127ea09ef65ff9f61ff6e02489223a70a3309089bf58dfe
6
+ metadata.gz: 4911d9ba97994da9366fd079f9997d0a7575fc34a488a93db82acfd197ebddce327b427408f0ac56d2aa98e3ff97a895736f618bdcd265984c5ca92d9fdcc9d9
7
+ data.tar.gz: ba64ce507488bbcf03d1e6d2144f79511e4662bec8cc49539d23cf802a7672d374fb1e39e6d7a068db9fcf3173f32a25b33cc711ca543eeb0bebbf9167c4953d
@@ -3,6 +3,65 @@ require 'omniauth-oauth2'
3
3
  module OmniAuth
4
4
  module Strategies
5
5
  class Streamlabs < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = 'donations.read'
7
+
8
+ option :name, "streamlabs"
9
+
10
+ option :client_options, {
11
+ site: 'https://streamlabs.com',
12
+ authorize_url: '/api/v1.0/authorize',
13
+ token_url: '/api/v1.0/token'
14
+ }
15
+
16
+ option :access_token_options, {
17
+ header_format: 'Bearer %s',
18
+ param_name: 'access_token'
19
+ }
20
+
21
+ option :authorize_options, [:scope]
22
+
23
+ uid{ raw_info['twitch']['id'] }
24
+
25
+ info do
26
+ {
27
+ display_name: raw_info['twitch']['display_name'],
28
+ name: raw_info['twitch']['name']
29
+ }
30
+ end
31
+
32
+ extra do
33
+ {
34
+ raw_info: raw_info
35
+ }
36
+ end
37
+
38
+ def raw_info
39
+ @raw_info ||= access_token.get('/api/v1.0/user').parsed
40
+ end
41
+
42
+ def build_access_token
43
+ super.tap do |token|
44
+ token.options.merge!(access_token_options)
45
+ end
46
+ end
47
+
48
+ def access_token_options
49
+ options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
50
+ end
51
+
52
+ def callback_url
53
+ return options[:redirect_uri] unless options[:redirect_uri].nil?
54
+ full_host + script_name + callback_path
55
+ end
56
+
57
+ def authorize_params
58
+ super.tap do |params|
59
+ options[:authorize_options].each do |k|
60
+ params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
61
+ end
62
+ params[:scope] = params[:scope] || DEFAULT_SCOPE
63
+ end
64
+ end
6
65
  end
7
66
  end
8
67
  end
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Streamlabs
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1 +1 @@
1
- require "omniauth/streamlabs/version"
1
+ require "omniauth/streamlabs"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-streamlabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Rohrer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2