I created a custom node with its own credential type. (For this, I am going off the Box node as reference because it’s an oauth2 request I wish to make).
In the properties, I define my properties as follows:
export class ODataOAuth2Api implements ICredentialType {
name = 'oDataOAuth2Api';
displayName = 'oData OAuth2 API';
extends = ['oAuth2Api'];
properties: INodeProperties[] = [
{
displayName: 'Grant Type',
name: 'grantType',
type: 'hidden',
default: 'authorizationCode',
},
{
displayName: 'Scope',
name: 'scope',
type: 'string',
default: 'testA',
required: true,
},
{
displayName: 'Authorization URL',
name: 'authUrl',
type: 'string',
default: '',
placeholder: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
required: true,
},
{
displayName: 'Access Token URL',
name: 'accessTokenUrl',
type: 'string',
default: '',
placeholder: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
required: true,
},
{
displayName: 'Scope2',
name: 'scope2',
type: 'string',
default: 'bla',
required: true,
},
{
displayName: 'Auth URI Query Parameters',
name: 'authQueryParameters',
type: 'hidden',
default: '',
},
{
displayName: 'Authentication',
name: 'authentication',
type: 'hidden',
default: 'body',
},
];
Now, I press ‘Connect my Account’ to connect with these values:
It will popup a login window at this url:
https://webhook.site/5c9e95c6-3a23-4b74-96dc-83c2b86115f2?client_id=4d7a47f0-0f8f-42fd-a9c4-ff91ec54b2b6&redirect_uri=http%3A%2F%2Flocalhost%3A5678%2Frest%2Foauth2-credential%2Fcallback&response_type=code&state=eyJ0b2tlbiI6Im8zZG5lR0gyLUdUWVAwX1hCY0JzLS1sSzRNZ0dzcTNlc29oQSIsImNpZCI6IjV3NURDWTljSDlRN0pVdGwifQ%3D%3D&scope=testA
(Notice, that ‘scope’ is given automatically as “testA” as a parameter in the URL).
Now, if I change the value of scope:
It retains its default value of ‘testA’ in the query:
...VdGwifQ%3D%3D&scope=testA
Thus, only the default value is ever used instead of the current value. This seems like a bug to me, but maybe I am doing something wrong.
Additionally, I changed Authorization URL, and the popup indeed went to a different URL, so it seems to be just the Scope parameter that is affected. Also, this happens regardless of setting Scope’s required field to true or false.
n8n Version: 1.58.2 on npm running on Node 18, SQLite