omniauth-twitch_smartcasual 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ed7de1304693eead94b576134dc473ea1eab7dd70d8adff78dd9d9498e4c54ce
4
+ data.tar.gz: 317d4633b2410d4c93b36bc4cb91a69b84da93ccbfc72d41434fa69e21701275
5
+ SHA512:
6
+ metadata.gz: 6fae25e1fb9b447b79db06d90e4eb2e4fc2937f228e21ebe12001321d9b1c26bbf322e15a964a1a843c47ced6229c5aaaa01541bf7ebe0f65118a0c8ace4c4d4
7
+ data.tar.gz: '0580f526feae7eec37aad27188f9a015cf9b2b65e1726e11b4f935facab292fcba9b3cf5da217c91adc7dd51c981ca7d141686b530d93555803d38c39312f986'
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-twitch.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Jonathan Gertig
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,69 @@
1
+ [![Gem Version](https://badge.fury.io/rb/omniauth-twitch.svg)](http://badge.fury.io/rb/omniauth-twitch)
2
+
3
+ # OmniAuth::Twitch
4
+
5
+ A OmniAuth strategy for Twitch recently updated to helix api
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'omniauth-twitch'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-twitch
20
+
21
+ ## Usage
22
+
23
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
24
+
25
+ ```ruby
26
+ Rails.application.config.middleware.use OmniAuth::Builder do
27
+ provider :twitch, ENV["TWITCH_CLIENT_ID"], ENV["TWITCH_CLIENT_SECRET"]
28
+ end
29
+ ```
30
+
31
+ ## Auth Hash
32
+
33
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
34
+
35
+ ```ruby
36
+ {
37
+ provider: 'twitch',
38
+ uid: '12345678',
39
+ info: {
40
+ name: 'JohnDoe',
41
+ email: 'johndoe@gmail.com',
42
+ nickname: 'johndoe',
43
+ description: 'My channel.',
44
+ image: 'http://static-cdn.jtvnw.net/jtv-static/404_preview-300x300.png',
45
+ urls: {
46
+ Twitch: 'http://www.twitch.tv/johndoe'
47
+ }
48
+ },
49
+ credentials: {
50
+ token: 'asdfghjklasdfghjklasdfghjkl', # OAuth 2.0 access_token, which you may wish to store
51
+ expires: false # this will always be false,
52
+ refresh_token: 'asdschbjh24h23yfsjfhbsjdc3a' # OAuth 2.0 refresh token, to renew the access token when it expires
53
+ },
54
+ extra: {
55
+ raw_info: {
56
+ display_name: 'JohnDoe',
57
+ id: '12345678',
58
+ login: 'johndoe',
59
+ type: '',
60
+ broadcaster_type: '',
61
+ description: 'My channel.',
62
+ profile_image_url: 'https://static-cdn.jtvnw.net/user-default-pictures/0ecbb6c3-fecb-4016-8115-aa467b7c36ed-profile_image-300x300.jpg',
63
+ offline_image_url: '',
64
+ view_count: 100500,
65
+ email: 'johdoe@gmail.com'
66
+ }
67
+ }
68
+ }
69
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,90 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Twitch < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = "user:read:email".freeze
7
+
8
+ option :name, "twitch"
9
+
10
+ option :client_options, {
11
+ site: "https://id.twitch.tv",
12
+ authorize_url: "/oauth2/authorize",
13
+ token_url: "/oauth2/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
+ def request_phase
24
+ redirect client.auth_code.
25
+ authorize_url({ redirect_uri: callback_url }.merge(authorize_params)).
26
+ gsub(/%2[b,B]/, "+")
27
+ end
28
+
29
+ credentials do
30
+ hash = { "token" => access_token.token }
31
+ if access_token.refresh_token
32
+ hash["refresh_token"] = access_token.refresh_token
33
+ end
34
+ hash["expires_at"] = access_token.expires_at if access_token.expires?
35
+ hash["expires"] = access_token.expires?
36
+ hash
37
+ end
38
+
39
+ uid { raw_info["id"] }
40
+
41
+ info do
42
+ {
43
+ name: raw_info["display_name"],
44
+ email: raw_info["email"],
45
+ nickname: raw_info["login"],
46
+ description: raw_info["description"],
47
+ image: raw_info["profile_image_url"],
48
+ urls: { Twitch: "http://www.twitch.tv/#{raw_info['login']}" }
49
+ }
50
+ end
51
+
52
+ extra do
53
+ {
54
+ raw_info: raw_info
55
+ }
56
+ end
57
+
58
+ def raw_info
59
+ @raw_info ||=
60
+ access_token.get("https://api.twitch.tv/helix/users",
61
+ headers: { "Client-ID" => client.id }).parsed.
62
+ fetch("data").fetch(0)
63
+ end
64
+
65
+ def build_access_token
66
+ super.tap do |token|
67
+ token.options.merge!(access_token_options)
68
+ end
69
+ end
70
+
71
+ def access_token_options
72
+ options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
73
+ end
74
+
75
+ def callback_url
76
+ return options[:redirect_uri] unless options[:redirect_uri].nil?
77
+ full_host + script_name + callback_path
78
+ end
79
+
80
+ def authorize_params
81
+ super.tap do |params|
82
+ options[:authorize_options].each do |k|
83
+ params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
84
+ end
85
+ params[:scope] = params[:scope] || DEFAULT_SCOPE
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Twitch
3
+ VERSION = "1.1.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/twitch/version"
2
+ require 'omniauth/strategies/twitch'
@@ -0,0 +1 @@
1
+ require 'omniauth/twitch'
@@ -0,0 +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/twitch/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-twitch_smartcasual"
8
+ spec.version = OmniAuth::Twitch::VERSION
9
+ spec.authors = ["Jonathan Gertig (Webtheory) and William Holt (Webtheory)"]
10
+ spec.email = ["jcgertig@gmail.com or sithtoast@gmail.com"]
11
+ spec.summary = 'Twitch OAuth2 Strategy for OmniAuth'
12
+ spec.homepage = "https://github.com/WebTheoryLLC/omniauth-twitch"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
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", "~> 2.1"
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-twitch_smartcasual
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Gertig (Webtheory) and William Holt (Webtheory)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-05-16 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.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
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:
56
+ email:
57
+ - jcgertig@gmail.com or sithtoast@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/omniauth-twitch.rb
68
+ - lib/omniauth/strategies/twitch.rb
69
+ - lib/omniauth/twitch.rb
70
+ - lib/omniauth/twitch/version.rb
71
+ - omniauth-twitch.gemspec
72
+ homepage: https://github.com/WebTheoryLLC/omniauth-twitch
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.3.7
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Twitch OAuth2 Strategy for OmniAuth
95
+ test_files: []