omniauth-goodgame 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e411f599f0ea95cd38842d919854edcdf1a4c05adc651487a2763668fb8ce9a1
4
- data.tar.gz: 311a27381db43067f26a614e0c82824b9e66846925da8b100197059346bc704a
3
+ metadata.gz: '029c7684f5a75abc853c3b28bcfd78b70e52e66fd5d2ec5cd1c0265cb40acf73'
4
+ data.tar.gz: 00e53bdae1cd987413cb8390d01e187d372568e1fbd142cab65b2c2ffe245326
5
5
  SHA512:
6
- metadata.gz: e7d528d076239ecf71292c197e69eb431c767cfaaa5b9ed5dbe3018e8e34941a83e6b1b84d25c7ee148dabb3b88ca7357f7dcd3dc6a129011c9cedb50ee15014
7
- data.tar.gz: b62d6c67a00d91aaa54fa8a1b7c8595d9da79ebe07834dbc003407ed9c1d6e68f73b62db6098cb70a71aebafdabc91035f2a33d8fad36a320ed867a13ee4ad00
6
+ metadata.gz: 8791c61174d8e8b99ce0051ff621a4fb1b9a7aeb92c0a2570cfd202bc245f1b05e25f6b4c3244fdd88dcbbe10055b9c255bd6bcb9f8b55799e72d0c55116dda7
7
+ data.tar.gz: 61bb7d5a5d95fdbfeef8bcde21811b910481b453e568d5399b86366ebb0127b474b3edc9f83bb40ad3055943006f2ae0ec050473df22e6d7becf5a8a48702bc5
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Omniauth
4
4
  module Goodgame
5
- VERSION = "0.0.4"
5
+ VERSION = "0.0.5"
6
6
  end
7
7
  end
@@ -1,60 +1,58 @@
1
- require "omniauth-oauth2"
1
+ require 'omniauth-oauth2'
2
2
 
3
3
  module OmniAuth
4
4
  module Strategies
5
5
  class Goodgame < OmniAuth::Strategies::OAuth2
6
- DEFAULT_SCOPE = ""
7
- option :name, "goodgame"
6
+ DEFAULT_SCOPE = ''
8
7
 
8
+ option :name, 'goodgame'
9
+ option :authorize_options, %i[scope display]
9
10
  option :client_options, {
10
- site: "https://goodgame.ru",
11
- authorize_url: "/oauth2/authorize",
12
- token_url: "/oauth2/token",
11
+ site: 'https://goodgame.ru',
12
+ authorize_url: '/oauth2/authorize',
13
+ token_url: '/oauth2/token',
13
14
  auth_scheme: :request_body
14
15
  }
15
-
16
16
  option :access_token_options, {
17
- header_format: "application/x-www-form-urlencoded",
18
- param_name: "access_token"
17
+ header_format: 'Bearer %s',
18
+ param_name: 'access_token'
19
19
  }
20
20
 
21
- option :authorize_options, [:scope]
22
-
23
21
  def request_phase
24
22
  redirect client.auth_code
25
23
  .authorize_url({ redirect_uri: callback_url }
26
- .merge(authorize_params)).gsub(/%2[b,B]/, "+")
24
+ .merge(authorize_params)).gsub(/%2[b,B]/, '+')
27
25
  end
28
26
 
29
27
  credentials do
30
- hash = { "token" => access_token.token }
31
- hash["refresh_token"] = access_token.refresh_token if access_token.refresh_token
32
- hash["expires_at"] = access_token.expires_at if access_token.expires?
33
- hash["expires"] = access_token.expires?
28
+ hash = { 'token' => access_token.token }
29
+ hash['refresh_token'] = access_token.refresh_token if access_token.refresh_token
30
+ hash['expires_at'] = access_token.expires_at if access_token.expires?
31
+ hash['expires'] = access_token.expires?
34
32
  hash
35
33
  end
36
34
 
37
- uid { raw_info["id"] }
35
+ uid { raw_info['id'] }
38
36
 
39
37
  info do
40
38
  {
41
- name: raw_info["nickname"],
42
- email: raw_info["email"],
43
- nickname: raw_info["username"],
44
- description: raw_info["about"],
45
- image: raw_info["avatar"],
46
- urls: { Goodgame: raw_info["link"] }
39
+ name: raw_info['nickname'],
40
+ email: raw_info['email']
47
41
  }
48
42
  end
43
+
49
44
  extra do
50
45
  {
51
- raw_info: raw_info
46
+ raw_info:
52
47
  }
53
48
  end
49
+
54
50
  def raw_info
55
- @raw_info ||=
56
- access_token.get("https://goodgame.ru/api/4/users/#{client.id}").parsed
57
- .fetch("data").fetch(0)
51
+ id = access_token.get("https://goodgame.ru/api/4/users/@me2?access_token=#{access_token.token}",
52
+ headers: { 'Accept' => 'application/json' }).parsed.fetch('id')
53
+ @raw_info =
54
+ access_token.get("https://goodgame.ru/api/4/users/#{id}?access_token=#{access_token.token}",
55
+ headers: { 'Accept' => 'application/json' }).parsed
58
56
  end
59
57
 
60
58
  def build_access_token
@@ -78,7 +76,7 @@ module OmniAuth
78
76
  def authorize_params
79
77
  super.tap do |params|
80
78
  options[:authorize_options].each do |k|
81
- params[k] = request.params[k.to_s] unless [nil, ""].include?(request.params[k.to_s])
79
+ params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
82
80
  end
83
81
  params[:scope] = params[:scope] || DEFAULT_SCOPE
84
82
  end
@@ -86,3 +84,4 @@ module OmniAuth
86
84
  end
87
85
  end
88
86
  end
87
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-goodgame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Seregin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-19 00:00:00.000000000 Z
11
+ date: 2023-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2