由于仅用于服务器的应用程序Im正在构建,因此我试图设置服务帐户来获取授权令牌,因此我需要开始将图片发送到google photos API。我一直在使用Google's guide进行设置,目前仍在为初始发布请求计算JWS。对于签名,我使用的是内置的加密程序包,但始终会遇到以下错误:
internal/crypto/sig.js:83
var ret = this._handle.sign(key, passphrase, rsaPadding, pssSaltLength);
^
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Sign.sign (internal/crypto/sig.js:83:26)
...
我在这里打电话:
const claimsOptions = {
"iss": "...", (this is filled in just removed for the post)
"sub": "...", (this is filled in just removed for the post)
"scope": "https://www.googleapis.com/auth/photoslibrary.appendonly",
"aud": "https://oauth2.googleapis.com/token",
"exp": 1328554385,
"iat": d.getTime(),
}
const encoding = {
"alg": "RS256",
"type": "JWT"
}
header = Buffer.from(JSON.stringify(encoding)).toString("base64");
claims = Buffer.from(JSON.stringify(claimsOptions)).toString("base64");
console.log(`${header}.${claims}`); //Returns a properly defined base64 string
const sign = crypto.createSign('RSA-SHA256');
sign.write(`${header}.${claims}`); //Writing that string to the signature
sign.end();
console.log(sign)
const signature = sign.sign(API_PRIVATE_KEY, "base64"); // Signing it using my API Key from my API Keys tab under console.developers.google.com
关于我在做什么错的任何想法?任何帮助都将不胜感激。