omniauth-bungie-oauth2 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -1
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/lib/oauth2/bungie_client.rb +1 -1
- data/lib/omniauth-bungie-oauth2/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1c3aa5d2f1b05dc0187ed37d39f075c66fb3b29
|
4
|
+
data.tar.gz: c9aad36bed6c0079d5e37db9eb3a622cce82d215
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 310acd967bf14533cd1d490992be687ead6bb733d102a5193f43ff65ce967319c350ae790868e8fb1a12eb1890fe25c099d11c7abea7eeff7f99ca1307aa8165
|
7
|
+
data.tar.gz: 67edafe5cce55d5f2c5e2eb39ab343e5eb9a679c86a687fe072b37e4beec746e50863368d665281c1c87fd40f9356d71468be35ef0afabc1c8856340e2d97b31
|
data/README.md
CHANGED
@@ -19,7 +19,9 @@ And then execute:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
|
22
|
+
### Settings
|
23
|
+
|
24
|
+
For full usage this gem You must create an application with authentication access on [Bungie.net](https://www.bungie.net/en/application).
|
23
25
|
|
24
26
|
After this, you can integrate this strategy with your application. (More about A Bungie OAuth2 you can read on [Help page](https://www.bungie.net/en/Help/Article/45481))
|
25
27
|
|
@@ -34,6 +36,57 @@ config.middleware.use OmniAuth::Builder do
|
|
34
36
|
end
|
35
37
|
~~~~
|
36
38
|
|
39
|
+
### Rails integration
|
40
|
+
|
41
|
+
For integration with Rails You have to setup your strategy configuration in `config/initializers/devise.rb`:
|
42
|
+
|
43
|
+
~~~~ruby
|
44
|
+
Devise.setup do |config|
|
45
|
+
config.omniauth :bungie,
|
46
|
+
'x_api_key_from_bungie_app_settings',
|
47
|
+
'authorization_url_from_bungie_app_settings',
|
48
|
+
:origin => 'origin_url_if_you_need'
|
49
|
+
end
|
50
|
+
~~~~
|
51
|
+
|
52
|
+
After this You should define omniauth callback in routes and controller.
|
53
|
+
|
54
|
+
**routes.rb:**
|
55
|
+
|
56
|
+
~~~~ruby
|
57
|
+
devise_for :users, :controllers => {
|
58
|
+
:omniauth_callbacks => 'devise/omniauth_callbacks',
|
59
|
+
}
|
60
|
+
~~~~
|
61
|
+
|
62
|
+
**devise/omniauth_callbacks_controller.rb**
|
63
|
+
|
64
|
+
~~~~ruby
|
65
|
+
class Devise::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
66
|
+
def bungie
|
67
|
+
@user = User.from_omniauth(request.env["omniauth.auth"])
|
68
|
+
|
69
|
+
if @user.persisted?
|
70
|
+
@user.remember_me = true
|
71
|
+
|
72
|
+
sign_in_and_redirect @user, :event => :authentication
|
73
|
+
|
74
|
+
set_flash_message(:notice, :success, :kind => 'Bungie') if is_navigational_format?
|
75
|
+
else
|
76
|
+
session["devise.bungie_data"] = request.env["omniauth.auth"]
|
77
|
+
|
78
|
+
redirect_to '/'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def failure
|
83
|
+
redirect_to '/'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
~~~~
|
87
|
+
|
88
|
+
### Result
|
89
|
+
|
37
90
|
After all manipulation the `request.env["omniauth.auth"]` have the next fields:
|
38
91
|
|
39
92
|
* `uid` with BungieNetUser membershipId
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/lib/oauth2/bungie_client.rb
CHANGED
@@ -36,7 +36,7 @@ module OAuth2
|
|
36
36
|
|
37
37
|
response = get_normalized_response(response)
|
38
38
|
|
39
|
-
raise(error) if options[:raise_errors] && !
|
39
|
+
raise(error) if options[:raise_errors] && (!response.is_a?(Hash) || response['access_token'].nil?)
|
40
40
|
|
41
41
|
access_token_class.from_hash(self, response.merge(access_token_opts))
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-bungie-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Ruban
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.6.8
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: A Bungie OAuth2 strategy for Omniauth
|