Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
flexisip
Commits
25344c42
Commit
25344c42
authored
1 year ago
by
Félix Olart
1
Browse files
Options
Download
Patches
Plain Diff
Fix wrong access token lifetime computation (FirebaseV1)
parent
348ae391
release/2.3
feat/presence_alias
fix/selinux_tag_not_set_on_install
2.3.4
1 merge request
!1134
fix: wrong access token lifetime computation (FirebaseV1)
Pipeline
#75929
failed with stages
in 37 minutes and 26 seconds
Changes
1
Pipelines
16
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/firebase_v1_get_access_token.py
+14
-3
scripts/firebase_v1_get_access_token.py
with
14 additions
and
3 deletions
scripts/firebase_v1_get_access_token.py
+
14
−
3
View file @
25344c42
...
...
@@ -18,6 +18,7 @@
"""
Retrieve a valid access token that can be used to authorize requests.
Lifetime is expressed in seconds.
All outputs of this script are printed in the standard output and formatted in JSON.
The structure is as follows: {"state": str ['ERROR', 'SUCCESS'], "data": obj, "warnings": list[str]}
...
...
@@ -86,17 +87,27 @@ if __name__ == "__main__":
request
=
google
.
auth
.
transport
.
requests
.
Request
()
credentials
.
refresh
(
request
)
# Make expiry an offset-aware datetime.
expiry
=
credentials
.
expiry
.
replace
(
tzinfo
=
datetime
.
timezone
.
utc
)
now
=
datetime
.
datetime
.
now
(
datetime
.
timezone
.
utc
)
lifetime
=
int
((
expiry
-
now
).
total_seconds
())
if
lifetime
<=
0
:
error
(
f
"computed token lifetime is negative or null (
{
lifetime
}
s) [now =
{
now
}
, expiry =
{
expiry
}
]"
)
sys
.
exit
(
0
)
data
=
{
"state"
:
ScriptState
.
SUCCESS
,
"data"
:
{
"token"
:
credentials
.
token
,
"lifetime"
:
int
(
credentials
.
expiry
.
timestamp
())
-
int
(
datetime
.
datetime
.
now
(
datetime
.
timezone
.
utc
).
timestamp
())
,
"lifetime"
:
lifetime
,
},
"warnings"
:
[
f
"
{
warning
.
message
}
"
for
warning
in
warnings
],
}
print
(
json
.
dumps
(
data
))
except
BaseException
as
exception
:
except
SystemExit
:
pass
except
BaseException
as
exception
:
error
(
f
"
{
exception
}
"
)
sys
.
exit
(
0
)
This diff is collapsed.
Click to expand it.
Félix Olart
@Failxxx
mentioned in commit
87fea44f
·
1 year ago
mentioned in commit
87fea44f
mentioned in commit 87fea44f234078bda3076154ffc5d2add6a8cd58
Toggle commit list
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets