fix(core): Fix oauth2 client credentials not always working (#5327)

fix oauth client credentials not working as expected
This commit is contained in:
Jonathan Bennetts 2023-02-01 18:05:21 +00:00 committed by GitHub
parent 59f290fe85
commit ec7575b032
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1029,7 +1029,10 @@ export async function requestOAuth2(
let oauthTokenData = credentials.oauthTokenData as clientOAuth2.Data;
// if it's the first time using the credentials, get the access token and save it into the DB.
if (credentials.grantType === OAuth2GrantType.clientCredentials && oauthTokenData === undefined) {
if (
credentials.grantType === OAuth2GrantType.clientCredentials &&
(oauthTokenData === undefined || Object.keys(oauthTokenData).length === 0)
) {
const { data } = await getClientCredentialsToken(oAuthClient, credentials);
// Find the credentials