authkeeper 0.1.3 → 0.1.4

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: 3fb703b887c4415e68a9ed91bea0a41cf1c682ccf20742d18c26700205f37a72
4
- data.tar.gz: f9ff63172357aab12de6252c5c58a764ec9e354921fc9199826d0876778ecbfb
3
+ metadata.gz: 780d37ca518a657c6988521b2ded293eba9caf428f624f8e4b8f38d4e10daaf3
4
+ data.tar.gz: f5a8b4aa60061ed901472f5d8d996c27c22909175107d9967b495c5b851ca200
5
5
  SHA512:
6
- metadata.gz: 633d17c8e59833d357dca0861cbfef908813a8668102ddff1e6760cc6e9aa3dc1fe249b3f7a194f4324d7c1722b97ba2684c2ed14b88993afea003943630bb73
7
- data.tar.gz: 902eef36cfcee239262871e13d1fd1eace8eca90f0b99449541d31ae46e94002c8943cc492d2b823861e2b2dff1c04f44bb5b51a68cef236b6a8a88553eb16c6
6
+ metadata.gz: 7e50531638b9dde0429275524fb1f57b7108374dc8a4a6c5574a510640ff0623451ab9124fef1a178d11418d839c73412433ac031ff84ffe8cd2ce8e3cf353db
7
+ data.tar.gz: 4049c78bf133b9a40ba4184460b0306aa8536dc31f7b136031739cf17a275d28df361fd8cfb8f2f50aa8327daa01b8eb62f473d40cff6c719666f5fd26b9afa5
@@ -3,7 +3,7 @@
3
3
  module Authkeeper
4
4
  module YandexAuthApi
5
5
  class Client < HttpService::Client
6
- include Requests::FetchAccessToken
6
+ include Requests::AccessToken
7
7
 
8
8
  BASE_URL = 'https://oauth.yandex.ru/'
9
9
 
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require 'base64'
5
+
6
+ module Authkeeper
7
+ module YandexAuthApi
8
+ module Requests
9
+ module AccessToken
10
+ def fetch_access_token(client_id:, client_secret:, code:)
11
+ post(
12
+ path: 'token',
13
+ body: URI.encode_www_form({
14
+ grant_type: 'authorization_code',
15
+ client_id: client_id,
16
+ client_secret: client_secret,
17
+ code: code
18
+ }),
19
+ headers: {
20
+ 'Content-Type' => 'application/x-www-form-urlencoded'
21
+ }
22
+ )
23
+ end
24
+
25
+ def refresh_access_token(client_id:, client_secret:, refresh_token:)
26
+ post(
27
+ path: 'token',
28
+ body: URI.encode_www_form({
29
+ grant_type: 'refresh_token',
30
+ refresh_token: refresh_token
31
+ }),
32
+ headers: {
33
+ 'Content-Type' => 'application/x-www-form-urlencoded',
34
+ 'Authorization' => "Basic #{authorization(client_id, client_secret)}"
35
+ }
36
+ )
37
+ end
38
+
39
+ private
40
+
41
+ def authorization(client_id, client_secret)
42
+ Base64.encode64("#{client_id}:#{client_secret}").gsub("\n", '')
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Authkeeper
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdanov Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-29 00:00:00.000000000 Z
11
+ date: 2024-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -58,7 +58,7 @@ files:
58
58
  - app/lib/authkeeper/yandex_api/client.rb
59
59
  - app/lib/authkeeper/yandex_api/requests/info.rb
60
60
  - app/lib/authkeeper/yandex_auth_api/client.rb
61
- - app/lib/authkeeper/yandex_auth_api/requests/fetch_access_token.rb
61
+ - app/lib/authkeeper/yandex_auth_api/requests/access_token.rb
62
62
  - app/mailers/authkeeper/application_mailer.rb
63
63
  - app/models/authkeeper/application_record.rb
64
64
  - app/services/authkeeper/fetch_session_service.rb
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'uri'
4
-
5
- module Authkeeper
6
- module YandexAuthApi
7
- module Requests
8
- module FetchAccessToken
9
- def fetch_access_token(client_id:, client_secret:, code:)
10
- post(
11
- path: 'token',
12
- body: URI.encode_www_form({
13
- grant_type: 'authorization_code',
14
- client_id: client_id,
15
- client_secret: client_secret,
16
- code: code
17
- }),
18
- headers: {
19
- 'Content-Type' => 'application/x-www-form-urlencoded'
20
- }
21
- )
22
- end
23
- end
24
- end
25
- end
26
- end