Hi N8N Team,
After integrating n8n in our product, I am removing the credentials dropdown and getting token from my DB and trying to pass the token for my API calls, while doing that i am getting error like "‘Authentication credentials were not provided.’ '"for the below code and n8n is getting terminated in terminal
Attached the code below
rpa_name = (await abmsInternalApiRequest.call(
this,
'GET',
endpoint,
{},
jwtToken,
)) as LoadedResource[];
export async function abmsInternalApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: string,
endpoint: string,
body: IDataObject = {},
jwtToken: any
) {
const credentials = (await this.getCredentials('abmsApi')) as AbmsCredentials;
const options: OptionsWithUri = {
method,
body,
uri: `${credentials.host}${endpoint}`,
json: true,
rejectUnauthorized: !credentials.allowUnauthorizedCerts,
headers: {
'token': {jwtToken}
}
};
try {
return await this.helpers.request!(options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
I have replaced
auth: {
user: credentials.username,
pass: credentials.password,
},
by
headers: {
'token': {jwtToken}
}
in the code after that this error coming , before it was working fine.
can you give me any example of how to pass the token for API calls?
Regards,
Praveen