omniauth-twitch 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15016713b12bafc994bf413fb0f92e59e15be754
4
+ data.tar.gz: f25b677273bf59195db5deb3a7056affe8baacde
5
+ SHA512:
6
+ metadata.gz: a43b2a067aa5563ac1c01d158e72bbe9716d3f41781fb5eabcaaba40ccd8b0f81a394a9fc2cb9b751f32951a1845ef66b86a1529ef637fe7bbfb4bcdcd229f0d
7
+ data.tar.gz: dcd2f3d1ea14e6e622225d162c2d359965bf27296cf3b2d0ec6878cf8efcd98b302b1da487163beddbb1235140b4ec02260fc4f63e987d85277a1cc001a16846
@@ -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
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 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.
@@ -0,0 +1,27 @@
1
+ # OmniAuth::Twitch
2
+
3
+ A OmniAuth strategy for Twitch
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-twitch'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-twitch
18
+
19
+ ## Usage
20
+
21
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :twitch, ENV["TWITCH_CLIENT_ID"], ENV["TWITCH_CLIENT_SECRET"]
26
+ end
27
+ ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require 'omniauth/twitch'
@@ -0,0 +1,67 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Twitch < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = 'user_read'
7
+
8
+ option :name, "twitch"
9
+
10
+ option :client_options, {
11
+ site: 'https://api.twitch.tv',
12
+ authorize_url: "/kraken/oauth2/authorize",
13
+ token_url: '/kraken/oauth2/token'
14
+ }
15
+
16
+ option :access_token_options, {
17
+ header_format: 'OAuth %s',
18
+ param_name: 'access_token'
19
+ }
20
+
21
+ option :authorize_options, [:scope]
22
+
23
+ uid{ raw_info['_id'] }
24
+
25
+ info do
26
+ {
27
+ display_name: raw_info['display_name'],
28
+ name: raw_info['name'],
29
+ email: raw_info['email'],
30
+ bio: raw_info['bio'],
31
+ logo: raw_info['logo'],
32
+ type: raw_info['type']
33
+ }
34
+ end
35
+
36
+ extra do
37
+ {
38
+ raw_info: raw_info
39
+ }
40
+ end
41
+
42
+ def raw_info
43
+ @raw_info ||= access_token.get('/kraken/user.json').parsed
44
+ end
45
+
46
+ def build_access_token
47
+ super.tap do |token|
48
+ token.options.merge!(access_token_options)
49
+ end
50
+ end
51
+
52
+ def access_token_options
53
+ options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
54
+ end
55
+
56
+ def authorize_params
57
+ super.tap do |params|
58
+ options[:authorize_options].each do |k|
59
+ params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
60
+ end
61
+
62
+ params[:scope] = params[:scope] || DEFAULT_SCOPE
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/twitch/version"
2
+ require 'omniauth/strategies/twitch'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Twitch
3
+ VERSION = "0.1.2"
4
+ end
5
+ end
@@ -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"
8
+ spec.version = OmniAuth::Twitch::VERSION
9
+ spec.authors = ["Jonathan Gertig"]
10
+ spec.email = ["jcgertig@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.1'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-twitch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Gertig
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-06 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
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
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
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
+ rubyforge_project:
92
+ rubygems_version: 2.2.1
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Twitch OAuth2 Strategy for OmniAuth
96
+ test_files: []