diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 1b3750a20..cc87aa897 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -1194,6 +1194,15 @@ class App { let options = {}; + const oAuth2Parameters = { + clientId: _.get(oauthCredentials, 'clientId') as string, + clientSecret: _.get(oauthCredentials, 'clientSecret', '') as string, + accessTokenUri: _.get(oauthCredentials, 'accessTokenUrl', '') as string, + authorizationUri: _.get(oauthCredentials, 'authUrl', '') as string, + redirectUri: `${WebhookHelpers.getWebhookBaseUrl()}${this.restEndpoint}/oauth2-credential/callback`, + scopes: _.split(_.get(oauthCredentials, 'scope', 'openid,') as string, ',') + }; + if (_.get(oauthCredentials, 'authentication', 'header') as string === 'body') { options = { body: { @@ -1201,16 +1210,10 @@ class App { client_secret: _.get(oauthCredentials, 'clientSecret', '') as string, }, }; + delete oAuth2Parameters.clientSecret; } - const oAuthObj = new clientOAuth2({ - clientId: _.get(oauthCredentials, 'clientId') as string, - clientSecret: _.get(oauthCredentials, 'clientSecret', '') as string, - accessTokenUri: _.get(oauthCredentials, 'accessTokenUrl', '') as string, - authorizationUri: _.get(oauthCredentials, 'authUrl', '') as string, - redirectUri: `${WebhookHelpers.getWebhookBaseUrl()}${this.restEndpoint}/oauth2-credential/callback`, - scopes: _.split(_.get(oauthCredentials, 'scope', 'openid,') as string, ',') - }); + const oAuthObj = new clientOAuth2(oAuth2Parameters); const oauthToken = await oAuthObj.code.getToken(req.originalUrl, options); diff --git a/packages/nodes-base/credentials/BitlyOAuth2Api.credentials.ts b/packages/nodes-base/credentials/BitlyOAuth2Api.credentials.ts index 2ba8ba3d3..0919e3063 100644 --- a/packages/nodes-base/credentials/BitlyOAuth2Api.credentials.ts +++ b/packages/nodes-base/credentials/BitlyOAuth2Api.credentials.ts @@ -7,7 +7,7 @@ import { export class BitlyOAuth2Api implements ICredentialType { name = 'bitlyOAuth2Api'; displayName = 'Bitly OAuth2 API'; - + extends = [ 'oAuth2Api', ]; @@ -55,25 +55,13 @@ export class BitlyOAuth2Api implements ICredentialType { type: 'hidden' as NodePropertyTypes, default: '', description: 'For some services additional query parameters have to be set which can be defined here.', - placeholder: 'access_type=offline', + placeholder: '', }, { displayName: 'Authentication', name: 'authentication', - type: 'options' as NodePropertyTypes, - options: [ - { - name: 'Body', - value: 'body', - description: 'Send credentials in body', - }, - { - name: 'Header', - value: 'header', - description: 'Send credentials as Basic Auth header', - }, - ], - default: 'header', + type: 'hidden' as NodePropertyTypes, + default: 'body', description: 'Resource to consume.', }, ]; diff --git a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts index 85a2c7094..edc8873a1 100644 --- a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts @@ -33,7 +33,8 @@ export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions | return await this.helpers.request!(options); } else { - return await this.helpers.requestOAuth2!.call(this, 'bitlyOAuth2Api', options); + //@ts-ignore + return await this.helpers.requestOAuth2!.call(this, 'bitlyOAuth2Api', options, 'Bearer'); } } catch(error) { throw new Error(error);