How to retrieve the secret key API using GAS ?

Hi,

I have developed a procedure to set a card signature in the GMAIL API  setting.parameter.  I have an error message in the delegation domain.....

With the help of a tutorial (see how to set domain user email signatures) I tried to develop this.

I can't find the API secret key because, in the encodeJwt_ function, (see below) I need to add the value of an API secret key. How to get  it back or to find it ?

function encodeJwt_(payload, key) {
Logger.log('Start function encodeJwt_(payload, key) ');
var header = {
alg: 'RS256',
type: 'JWT'
};

Logger.log('function encodeJwt_(payload, key) - header '+header);
Logger.log('function encodeJwt_(payload, key) - payload '+payload);
Logger.log('function encodeJwt_(payload, key) - key '+key);


var privateKey = "-----BEGIN PRIVATE KEY-----\n"+key+"\n-----END PRIVATE KEY-----\n"
Logger.log('function encodeJwt_(payload, key) - privateKey '+privateKey);

var toSign = Utilities.base64EncodeWebSafe(JSON.stringify(header)) + '.' +
Utilities.base64EncodeWebSafe(JSON.stringify(payload));
Logger.log('function encodeJwt_(payload, key) - toSign 1:'+ toSign);


toSign = toSign.replace(/=+$/, '');
Logger.log('function encodeJwt_(payload, key) - toSign 2:'+ toSign);

var signatureBytes =
Utilities.computeRsaSha256Signature(toSign, privateKey);
var signature = Utilities.base64EncodeWebSafe(signatureBytes);

Logger.log('End function encodeJwt_(payload, key) ');
return toSign + '.' + signature;
}

Could you send me, please,  the link if you know the VIDEO tutorial about finding or recovering the value of the SECRET API key please? This would help me more easily because, sometimes, I have difficulty understanding the documentation in English, my level is not that great...

In advance thank you for your answer

 

 

0 0 90
0 REPLIES 0
Top Labels in this Space