mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
⚡ Automatically remove new lines from Google credentials
This commit is contained in:
parent
205ae0986f
commit
185bc04436
|
@ -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',
|
||||
},
|
||||
|
|
|
@ -32,7 +32,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
|||
uri: uri || `https://www.googleapis.com${resource}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
|
||||
options = Object.assign({}, options, option);
|
||||
|
||||
try {
|
||||
|
@ -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',
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue