Describe the problem/error/question
hello. i have problem.
i made good working code at n8n v1.68.1. but it is not working latest version.
The following code (//HERE!! section) works fine in n8n version 1.68.1 but does not work in versions 1.80.3 and 1.78.0
- The credential for Solapi API is created successfully.
- A workflow’s HTTP request node is created.
- In the authentication settings of the HTTP request node:
Authentication - Select Predefined Credential Type
Here,
- In version 1.68.0: The credential type “Solapi API” is visible and selectable.
- In version 1.80.3: “Solapi API” is not visible and cannot be used.
Is async authenticate
not supported in the latest versions (such as 1.80.3)?
thanks for reading
code
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
ICredentialDataDecryptedObject,
IHttpRequestHelper,
IHttpRequestOptions
} from 'n8n-workflow';
import * as crypto from 'crypto'
export class AllabuSolapiKakaoApi implements ICredentialType {
name = 'allabusolapikakaoApi';
displayName = 'Solapi API';
properties: INodeProperties[] = [
{
displayName: 'API KEY',
name: 'apiKey',
type: 'string',
typeOptions: {
password: false,
},
default: '',
},
{
displayName: 'API secret',
name: 'apiSecret',
type: 'string',
typeOptions: {
password: true,
},
default: '',
},
];
// HERE!!! authenticate doesn't work n8n v1.80.3
async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
console.log('preAuthenticate called with credentials:', credentials);
const apiKey = credentials.apiKey;
const salt = 'jqsba2jxjnrjor';//crypto.randomBytes(16).toString('hex');
const dateTime = new Date().toISOString();
const signatureString = dateTime + salt;
const apiSecret = String(credentials.apiSecret);
const signature = crypto.createHmac('sha256', apiSecret).update(signatureString).digest('hex');
const authString = 'HMAC-SHA256 apiKey=' + apiKey + ', date=' + dateTime + ', salt=' + salt + ', signature=' + signature;
console.log("authString: ", authString);
// requestOptions.headers!.Authorization = authString;
requestOptions.headers = {
Accept: 'application/json',
'X-Ninja-Token': authString,
};
return requestOptions;
}
/* not using
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
// This will be set dynamically in the `preAuthenticate` function
headers: {
'Authorization': 'authString',
},
},
};
not using */
}
What is the error message (if any)?
good working(v1.68.1) - same code
not working(v1.80.1) - same code
Please share your workflow
Information on your n8n setup
- n8n version:1.80.3
- Database (default: SQLite):default
- n8n EXECUTIONS_PROCESS setting (default: own, main):default
- Running n8n via (Docker, npm, n8n cloud, desktop app):npm
- Operating system:ubuntu(linux)