mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix(core): Fix OAuth credential creation via API (#5064)
* fix(core): Fix OAuth credential creation via API * Fix tests
This commit is contained in:
parent
62b2fc37c3
commit
93da026c0d
|
@ -299,6 +299,21 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (credentialTypeData.extends === undefined) {
|
if (credentialTypeData.extends === undefined) {
|
||||||
|
// Manually add the special OAuth parameter which stores
|
||||||
|
// data like access- and refresh-token
|
||||||
|
if (['oAuth1Api', 'oAuth2Api'].includes(type)) {
|
||||||
|
return [
|
||||||
|
...credentialTypeData.properties,
|
||||||
|
{
|
||||||
|
displayName: 'oauthTokenData',
|
||||||
|
name: 'oauthTokenData',
|
||||||
|
type: 'json',
|
||||||
|
required: false,
|
||||||
|
default: {},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return credentialTypeData.properties;
|
return credentialTypeData.properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,9 @@ export function toJsonSchema(properties: INodeProperties[]): IDataObject {
|
||||||
// to later validate that only this properties are set in
|
// to later validate that only this properties are set in
|
||||||
// the credentials sent in the API call.
|
// the credentials sent in the API call.
|
||||||
properties.forEach((property) => {
|
properties.forEach((property) => {
|
||||||
requiredFields.push(property.name);
|
if (property.required) {
|
||||||
|
requiredFields.push(property.name);
|
||||||
|
}
|
||||||
if (property.type === 'options') {
|
if (property.type === 'options') {
|
||||||
// if the property is type options,
|
// if the property is type options,
|
||||||
// include all possible values in the enum property.
|
// include all possible values in the enum property.
|
||||||
|
|
|
@ -206,18 +206,21 @@ export function gitHubCredentialType(): ICredentialType {
|
||||||
name: 'server',
|
name: 'server',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'https://api.github.com',
|
default: 'https://api.github.com',
|
||||||
|
required: true,
|
||||||
description: 'The server to connect to. Only has to be set if Github Enterprise is used.',
|
description: 'The server to connect to. Only has to be set if Github Enterprise is used.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'User',
|
displayName: 'User',
|
||||||
name: 'user',
|
name: 'user',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
required: true,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Access Token',
|
displayName: 'Access Token',
|
||||||
name: 'accessToken',
|
name: 'accessToken',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
required: true,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue