mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Automatically remove new lines from Google credentials
This commit is contained in:
@@ -87,6 +87,8 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
|
||||
const now = moment().unix();
|
||||
|
||||
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||
|
||||
const signature = jwt.sign(
|
||||
{
|
||||
'iss': credentials.email as string,
|
||||
@@ -96,11 +98,11 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
'iat': now,
|
||||
'exp': now + 3600,
|
||||
},
|
||||
credentials.privateKey as string,
|
||||
privateKey as string,
|
||||
{
|
||||
algorithm: 'RS256',
|
||||
header: {
|
||||
'kid': credentials.privateKey as string,
|
||||
'kid': privateKey as string,
|
||||
'typ': 'JWT',
|
||||
'alg': 'RS256',
|
||||
},
|
||||
|
||||
@@ -95,6 +95,8 @@ function getAccessToken(this: IExecuteFunctions | ILoadOptionsFunctions, credent
|
||||
|
||||
const now = moment().unix();
|
||||
|
||||
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||
|
||||
const signature = jwt.sign(
|
||||
{
|
||||
'iss': credentials.email as string,
|
||||
@@ -104,11 +106,11 @@ function getAccessToken(this: IExecuteFunctions | ILoadOptionsFunctions, credent
|
||||
'iat': now,
|
||||
'exp': now + 3600,
|
||||
},
|
||||
credentials.privateKey as string,
|
||||
privateKey as string,
|
||||
{
|
||||
algorithm: 'RS256',
|
||||
header: {
|
||||
'kid': credentials.privateKey as string,
|
||||
'kid': privateKey as string,
|
||||
'typ': 'JWT',
|
||||
'alg': 'RS256',
|
||||
},
|
||||
|
||||
@@ -94,6 +94,8 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
|
||||
const now = moment().unix();
|
||||
|
||||
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||
|
||||
const signature = jwt.sign(
|
||||
{
|
||||
'iss': credentials.email as string,
|
||||
@@ -103,11 +105,11 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
'iat': now,
|
||||
'exp': now + 3600,
|
||||
},
|
||||
credentials.privateKey as string,
|
||||
privateKey as string,
|
||||
{
|
||||
algorithm: 'RS256',
|
||||
header: {
|
||||
'kid': credentials.privateKey as string,
|
||||
'kid': privateKey as string,
|
||||
'typ': 'JWT',
|
||||
'alg': 'RS256',
|
||||
},
|
||||
|
||||
@@ -216,6 +216,8 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
|
||||
const now = moment().unix();
|
||||
|
||||
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||
|
||||
const signature = jwt.sign(
|
||||
{
|
||||
'iss': credentials.email as string,
|
||||
@@ -225,11 +227,11 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
'iat': now,
|
||||
'exp': now + 3600,
|
||||
},
|
||||
credentials.privateKey as string,
|
||||
privateKey,
|
||||
{
|
||||
algorithm: 'RS256',
|
||||
header: {
|
||||
'kid': credentials.privateKey as string,
|
||||
'kid': privateKey,
|
||||
'typ': 'JWT',
|
||||
'alg': 'RS256',
|
||||
},
|
||||
@@ -252,4 +254,3 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
//@ts-ignore
|
||||
return this.helpers.request(options);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,8 @@ export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions
|
||||
|
||||
const now = moment().unix();
|
||||
|
||||
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||
|
||||
const signature = jwt.sign(
|
||||
{
|
||||
'iss': credentials.email as string,
|
||||
@@ -102,11 +104,11 @@ export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions
|
||||
'iat': now,
|
||||
'exp': now + 3600,
|
||||
},
|
||||
credentials.privateKey as string,
|
||||
privateKey,
|
||||
{
|
||||
algorithm: 'RS256',
|
||||
header: {
|
||||
'kid': credentials.privateKey as string,
|
||||
'kid': privateKey,
|
||||
'typ': 'JWT',
|
||||
'alg': 'RS256',
|
||||
},
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
IDataObject,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
@@ -64,7 +65,7 @@ export async function googleApiRequest(
|
||||
|
||||
function getAccessToken(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
{ email, privateKey }: { email: string, privateKey: string },
|
||||
credentials: ICredentialDataDecryptedObject,
|
||||
) {
|
||||
// https://developers.google.com/identity/protocols/oauth2/service-account#httprest
|
||||
|
||||
@@ -75,10 +76,12 @@ function getAccessToken(
|
||||
|
||||
const now = moment().unix();
|
||||
|
||||
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||
|
||||
const signature = jwt.sign(
|
||||
{
|
||||
iss: email,
|
||||
sub: email,
|
||||
iss: credentials.email,
|
||||
sub: credentials.email,
|
||||
scope: scopes.join(' '),
|
||||
aud: 'https://oauth2.googleapis.com/token',
|
||||
iat: now,
|
||||
|
||||
@@ -86,6 +86,8 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
|
||||
const now = moment().unix();
|
||||
|
||||
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||
|
||||
const signature = jwt.sign(
|
||||
{
|
||||
'iss': credentials.email as string,
|
||||
@@ -95,11 +97,11 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
||||
'iat': now,
|
||||
'exp': now + 3600,
|
||||
},
|
||||
credentials.privateKey as string,
|
||||
privateKey as string,
|
||||
{
|
||||
algorithm: 'RS256',
|
||||
header: {
|
||||
'kid': credentials.privateKey as string,
|
||||
'kid': privateKey as string,
|
||||
'typ': 'JWT',
|
||||
'alg': 'RS256',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user