zaikio-oauth_client 0.19.2 → 0.19.3
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 +4 -4
- data/lib/zaikio/oauth_client/version.rb +1 -1
- data/lib/zaikio/oauth_client.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58d2e1d10678b7eddb4afc7931c94e04299b63027c3b02c5773e03bf74b29b7d
|
4
|
+
data.tar.gz: 44459fbc11ec98ccdd1f88819416f50b704a1d9f1a32a7a24d17a92b863563e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4dd805f5c186d1d502afd9788b77ed7f9178672c841b03d7f9c5c97f81d5dc3243a255f1087f1e49bc312a024b4758df7599e871efcd650e34097527c927e51
|
7
|
+
data.tar.gz: 025cfe46f4cdc9cb9138b814d86a82f3b7590a6fba2e1261bbe420ba6d16a43392eb88306500a02a2fa5cc3047a7970a24e7c6e28fc6bf91dcc6833554d5165a
|
data/lib/zaikio/oauth_client.rb
CHANGED
@@ -80,7 +80,7 @@ module Zaikio
|
|
80
80
|
|
81
81
|
# This method can be used to find an active access token by id.
|
82
82
|
# It might refresh the access token to get an active one.
|
83
|
-
def find_active_access_token(id)
|
83
|
+
def find_active_access_token(id, valid_for: 30.seconds)
|
84
84
|
return unless id
|
85
85
|
|
86
86
|
if Rails.env.test?
|
@@ -88,7 +88,9 @@ module Zaikio
|
|
88
88
|
return access_token if access_token
|
89
89
|
end
|
90
90
|
|
91
|
-
access_token = Zaikio::AccessToken.
|
91
|
+
access_token = Zaikio::AccessToken.valid(valid_for.from_now).or(
|
92
|
+
Zaikio::AccessToken.valid_refresh(valid_for.from_now)
|
93
|
+
).find_by(id: id)
|
92
94
|
access_token = access_token.refresh! if access_token&.expired?
|
93
95
|
|
94
96
|
access_token
|