diff --git a/packages/next-drupal/src/client.ts b/packages/next-drupal/src/client.ts index f66ff9bc..d7da07ca 100644 --- a/packages/next-drupal/src/client.ts +++ b/packages/next-drupal/src/client.ts @@ -1316,17 +1316,22 @@ export class DrupalClient { } if ( - !isClientIdSecretAuth(this._auth) || - (opts && !isClientIdSecretAuth(opts)) + !isClientIdSecretAuth(this._auth) && + opts && + !isClientIdSecretAuth(opts) ) { throw new Error( `'clientId' and 'clientSecret' required. See https://next-drupal.org/docs/client/auth` ) } - const clientId = opts?.clientId || this._auth.clientId - const clientSecret = opts?.clientSecret || this._auth.clientSecret - const url = this.buildUrl(opts?.url || this._auth.url || DEFAULT_AUTH_URL) + const auth = isClientIdSecretAuth(opts) + ? opts + : (this._auth as DrupalClientAuthClientIdSecret) + + const clientId = auth.clientId + const clientSecret = auth.clientSecret + const url = this.buildUrl(auth.url || DEFAULT_AUTH_URL) if ( this.accessTokenScope === opts?.scope &&