omniauth-streamelements 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +56 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/omniauth/strategies/streamelements.rb +77 -0
- data/lib/omniauth/streamelements/version.rb +5 -0
- data/lib/omniauth/streamelements.rb +2 -0
- data/lib/omniauth-streamelements.rb +1 -0
- data/omniauth-streamelements.gemspec +24 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a6851adac907891a2363dd87689cdb71abd7795656232c4bb744e756814367cb
|
4
|
+
data.tar.gz: 8657fe4c6c31b272d5345c71896a29714e8130abe9a65976d750e674b1cd2533
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b3695030a9523dc2a763f93df4fb52b3d9c4d01f66cf5ff5fcde847795da3a3dd24d4a013bfee4bfaf4e8f62ce1335aa8fd0aeb88a0375626b13b4b6a57c30b7
|
7
|
+
data.tar.gz: c22d3cdcabde79ef6bcd8d8293ea81e056fc80655ebb507a3532784d6e32073ffdd5e1cf5cec0927735e1bec7c0fd282d27695f4b0d52cdc931168527683bafe
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at matt@prognostikos.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Matt Rohrer
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Omniauth::Streamelements
|
2
|
+
|
3
|
+
An Omniauth strategy for Streamelements
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-streamelements', github: "krtschmr/omniauth-streamelements"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
23
|
+
provider :streamelements, ENV["STREAMELEMENTS_CLIENT_ID"], ENV["STREAMELEMENTS_CLIENT_SECRET"]
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
## Auth Hash
|
28
|
+
|
29
|
+
Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
{"provider"=>"streamelements",
|
33
|
+
"uid"=>"5d2....",
|
34
|
+
"info"=>{"display_name"=>"MyHero", "name"=>"MyHero"},
|
35
|
+
"credentials"=>{"token"=>"CvsQp....", "refresh_token"=>"e8N...", "expires_at"=>1578133337, "expires"=>true},
|
36
|
+
"extra"=>
|
37
|
+
{"raw_info"=>
|
38
|
+
{"streamelements"=>
|
39
|
+
{"profile"=>{"headerImage"=>"....", "title"=>"...'s profile"},
|
40
|
+
"provider"=>"twitch",
|
41
|
+
"broadcasterType"=>"affiliate",
|
42
|
+
"suspended"=>false,
|
43
|
+
"providerId"=>"1337",
|
44
|
+
...
|
45
|
+
"geo"=>"TH",
|
46
|
+
"id"=>"5d29bb4406f75d15ac92a9c3"}}}}
|
47
|
+
|
48
|
+
```
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/krtschmr/omniauth-streamelements. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "omniauth/streamelements"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Streamelements < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_SCOPE = 'tips:write'.freeze
|
7
|
+
|
8
|
+
option :name, "streamelements"
|
9
|
+
|
10
|
+
option :client_options, {
|
11
|
+
site: 'https://api.streamelements.com',
|
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
|
+
uid do
|
24
|
+
raw_info['streamelements']['id']
|
25
|
+
end
|
26
|
+
|
27
|
+
info do
|
28
|
+
{
|
29
|
+
display_name: raw_info['streamelements']['username'],
|
30
|
+
name: raw_info['streamelements']['displayName']
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
extra do
|
35
|
+
{ raw_info: raw_info }
|
36
|
+
end
|
37
|
+
|
38
|
+
def raw_info
|
39
|
+
@raw_info ||= get_raw_info
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_raw_info
|
43
|
+
uri = URI("https://api.streamelements.com/kappa/v2/channels/me")
|
44
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
45
|
+
http.use_ssl = true
|
46
|
+
resp = http.get(uri.path, {'Authorization'=>"OAuth #{access_token.token}"})
|
47
|
+
data = JSON.parse(resp.body)
|
48
|
+
data["id"] = data.delete("_id")
|
49
|
+
{"streamelements" => data}
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_access_token
|
53
|
+
super.tap do |token|
|
54
|
+
token.options.merge!(access_token_options)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def access_token_options
|
59
|
+
options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
|
60
|
+
end
|
61
|
+
|
62
|
+
def callback_url
|
63
|
+
return options[:redirect_uri] unless options[:redirect_uri].nil?
|
64
|
+
full_host + script_name + callback_path
|
65
|
+
end
|
66
|
+
|
67
|
+
def authorize_params
|
68
|
+
super.tap do |params|
|
69
|
+
options[:authorize_options].each do |k|
|
70
|
+
params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
|
71
|
+
end
|
72
|
+
params[:scope] = params[:scope] || DEFAULT_SCOPE
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "omniauth/streamelements"
|
@@ -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/streamelements/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-streamelements"
|
8
|
+
spec.version = OmniAuth::Streamelements::VERSION
|
9
|
+
spec.authors = ["Tim Kretschmer"]
|
10
|
+
spec.email = ["tim@krtschmr.de"]
|
11
|
+
|
12
|
+
spec.summary = %q{Streamelements OAuth2 strategy for OmniAuth}
|
13
|
+
spec.homepage = "https://github.com/krtschmr/omniauth-streamelements"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.6'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-streamelements
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Kretschmer
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-09-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
|
+
description:
|
28
|
+
email:
|
29
|
+
- tim@krtschmr.de
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- CODE_OF_CONDUCT.md
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- bin/console
|
41
|
+
- bin/setup
|
42
|
+
- lib/omniauth-streamelements.rb
|
43
|
+
- lib/omniauth/strategies/streamelements.rb
|
44
|
+
- lib/omniauth/streamelements.rb
|
45
|
+
- lib/omniauth/streamelements/version.rb
|
46
|
+
- omniauth-streamelements.gemspec
|
47
|
+
homepage: https://github.com/krtschmr/omniauth-streamelements
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata: {}
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.5.11
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Streamelements OAuth2 strategy for OmniAuth
|
70
|
+
test_files: []
|