omniauth-betable 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +11 -0
- data/Guardfile +11 -0
- data/README.md +55 -0
- data/Rakefile +9 -0
- data/lib/omniauth/strategies/betable.rb +51 -0
- data/lib/omniauth-betable/version.rb +5 -0
- data/lib/omniauth-betable.rb +2 -0
- data/omniauth-betable.gemspec +26 -0
- metadata +122 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
OmniAuth Betable
|
2
|
+
==============
|
3
|
+
|
4
|
+
This gem contains the Betable strategy for OmniAuth.
|
5
|
+
|
6
|
+
For more information about the Betable api: http://developers.betable.com/
|
7
|
+
|
8
|
+
How To Use It
|
9
|
+
-------------
|
10
|
+
|
11
|
+
If you are using rails, you need to add the gem to your `Gemfile`:
|
12
|
+
|
13
|
+
gem 'omniauth-betable'
|
14
|
+
|
15
|
+
You can pull them in directly from github e.g.:
|
16
|
+
|
17
|
+
gem "omniauth-betable", :git => "git://github.com/stefanobernardi/omniauth-betable.git"
|
18
|
+
|
19
|
+
Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
|
20
|
+
|
21
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
22
|
+
provider :betable, 'api_key', 'api_secret'
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
You will obviously have to put in your key and secret, which you can get from the game dashboard.
|
27
|
+
|
28
|
+
|
29
|
+
After you have the gem running and the configuration is done, you can get to the follow url to log the user in:
|
30
|
+
|
31
|
+
http://localhost:3000/auth/betable
|
32
|
+
|
33
|
+
The Omniauth Hash will look like this:
|
34
|
+
|
35
|
+
#<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash expires=false token="ACCESS_TOKEN"> extra=#<OmniAuth::AuthHash raw_info=#<OmniAuth::AuthHash first_name="Stefano" id="oIt0z5JsHXiRS0Ez" last_name="Bernardi">> info=#<OmniAuth::AuthHash::InfoHash first_name="Stefano" last_name="Bernardi"> provider="betable" uid="oIt0z5JsHXiRS0Ez">
|
36
|
+
|
37
|
+
In your game configuration on developers.betable.com you should set the redirect URI to:
|
38
|
+
|
39
|
+
http://your_server:port/auth/betable/callback
|
40
|
+
|
41
|
+
Questions
|
42
|
+
---------
|
43
|
+
|
44
|
+
For any question, fell free to send me a tweet http://twitter.com/betableAPI
|
45
|
+
|
46
|
+
License
|
47
|
+
-------
|
48
|
+
|
49
|
+
Copyright (c) 2013 by Stefano Bernardi
|
50
|
+
|
51
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
52
|
+
|
53
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Betable < OmniAuth::Strategies::OAuth2
|
7
|
+
option :name, 'betable'
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
:site => 'https://betable.com',
|
11
|
+
:authorize_url => 'https://betable.com/authorize',
|
12
|
+
:token_url => 'https://api.betable.com/1.0/token'
|
13
|
+
}
|
14
|
+
|
15
|
+
uid { raw_info['id'] }
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
:first_name => raw_info['first_name'],
|
20
|
+
:last_name => raw_info['last_name']
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
extra do
|
25
|
+
{
|
26
|
+
:raw_info => raw_info
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def raw_info
|
31
|
+
access_token.options[:mode] = :query
|
32
|
+
access_token.options[:param_name] = :access_token
|
33
|
+
@raw_info ||= MultiJson.load(access_token.get('https://api.betable.com/1.0/account').body)
|
34
|
+
end
|
35
|
+
|
36
|
+
def request_phase
|
37
|
+
redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params.merge(request.params)))
|
38
|
+
end
|
39
|
+
|
40
|
+
def build_access_token
|
41
|
+
headers = {
|
42
|
+
:headers => {
|
43
|
+
'Authorization' => "Basic " + Base64.encode64(client.id + ":" + client.secret).gsub(/\n/, '')
|
44
|
+
}
|
45
|
+
}
|
46
|
+
verifier = request.params['code']
|
47
|
+
client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)).merge(headers))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-betable/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.add_dependency 'omniauth'
|
6
|
+
gem.add_dependency 'oauth2'
|
7
|
+
|
8
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
9
|
+
gem.add_development_dependency 'rack-test'
|
10
|
+
gem.add_development_dependency 'webmock'
|
11
|
+
gem.add_development_dependency 'simplecov'
|
12
|
+
|
13
|
+
gem.authors = ["Stefano Bernardi"]
|
14
|
+
gem.email = ["stefano@betable.com"]
|
15
|
+
gem.description = %q{Betable strategy for OmniAuth.}
|
16
|
+
gem.summary = %q{Betable strategy for OmniAuth.}
|
17
|
+
gem.homepage = "https://github.com/stefanobernardi/omniauth-betable"
|
18
|
+
gem.license = "MIT"
|
19
|
+
|
20
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
gem.files = `git ls-files`.split("\n")
|
22
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
gem.name = "omniauth-betable"
|
24
|
+
gem.require_paths = ["lib"]
|
25
|
+
gem.version = OmniAuth::Betable::VERSION
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-betable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Stefano Bernardi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: &70264549719780 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70264549719780
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: oauth2
|
27
|
+
requirement: &70264549718860 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70264549718860
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70264549718340 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.7'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70264549718340
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rack-test
|
49
|
+
requirement: &70264549717900 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70264549717900
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: webmock
|
60
|
+
requirement: &70264549717240 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70264549717240
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: &70264549716640 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70264549716640
|
80
|
+
description: Betable strategy for OmniAuth.
|
81
|
+
email:
|
82
|
+
- stefano@betable.com
|
83
|
+
executables: []
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- .gitignore
|
88
|
+
- .rspec
|
89
|
+
- Gemfile
|
90
|
+
- Guardfile
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- lib/omniauth-betable.rb
|
94
|
+
- lib/omniauth-betable/version.rb
|
95
|
+
- lib/omniauth/strategies/betable.rb
|
96
|
+
- omniauth-betable.gemspec
|
97
|
+
homepage: https://github.com/stefanobernardi/omniauth-betable
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.8.15
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: Betable strategy for OmniAuth.
|
122
|
+
test_files: []
|