-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Connectors] ConnectorTokenClient
improvements
#131955
Changes from 9 commits
4cc3386
4d197fb
e2ec8df
787376a
3cc6bf8
1e324ba
3673c23
603a206
a9f3c34
23fd5a6
ab56dc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,9 @@ export const getOAuthClientCredentialsAccessToken = async ({ | |
} | ||
|
||
if (connectorToken === null || Date.parse(connectorToken.expiresAt) <= Date.now()) { | ||
// Save the time before requesting token so we can use it to calculate expiration | ||
const requestTokenStart = Date.now(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using the time before requesting the token to calculate the expiration time of the token. previously, the expiration was calculated using a |
||
|
||
// request access token with jwt assertion | ||
const tokenResult = await requestOAuthClientCredentialsToken( | ||
tokenUrl, | ||
|
@@ -82,6 +85,7 @@ export const getOAuthClientCredentialsAccessToken = async ({ | |
connectorId, | ||
token: connectorToken, | ||
newToken: accessToken, | ||
tokenRequestDate: requestTokenStart, | ||
expiresInSec: tokenResult.expiresIn, | ||
deleteExisting: hasErrors, | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
Date.parse(expiresAt)
isNaN
, then checking whether the token had expired would always returnfalse
, causing us to keep using the same access token repeatedly.