Skip to content

Commit

Permalink
fix(core): Fix oauth2 client credentials not always working (#5327)
Browse files Browse the repository at this point in the history
fix oauth client credentials not working as expected
  • Loading branch information
Joffcom authored Feb 1, 2023
1 parent 59f290f commit ec7575b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec7575b

Please sign in to comment.