我最近在 Node.js 上使用 google 云存储 SDK 时遇到了这个错误。我知道这在过去没有任何改变的情况下是有效的,但我已经有一段时间没有接触代码了,可能是错误的。
这是错误本身:
Error: error:1E08010C:DECODER routines::unsupported
at Sign.sign (node:internal/crypto/sig:131:29)
at Object.sign (node_modules/jwa/index.js:152:45)
at Object.jwsSign [as sign] (node_modules/jws/lib/sign-stream.js:32:24)
at GoogleToken.requestToken (node_modules/gtoken/build/src/index.js:232:31)
at GoogleToken.getTokenAsyncInner (node_modules/gtoken/build/src/index.js:166:21)
at GoogleToken.getTokenAsync (node_modules/gtoken/build/src/index.js:145:55)
at GoogleToken.getToken (node_modules/gtoken/build/src/index.js:97:21)
at JWT.refreshTokenNoCache (node_modules/google-auth-library/build/src/auth/jwtclient.js:172:36)
at JWT.refreshToken (node_modules/google-auth-library/build/src/auth/oauth2client.js:153:24)
at JWT.getRequestMetadataAsync (node_modules/google-auth-library/build/src/auth/oauth2client.js:298:28) {
library: 'DECODER routines',
reason: 'unsupported',
code: 'ERR_OSSL_UNSUPPORTED'
}
Run Code Online (Sandbox Code Playgroud)
引发此错误的代码如下:
Error: error:1E08010C:DECODER routines::unsupported
at Sign.sign (node:internal/crypto/sig:131:29)
at Object.sign (node_modules/jwa/index.js:152:45)
at Object.jwsSign [as sign] (node_modules/jws/lib/sign-stream.js:32:24)
at GoogleToken.requestToken (node_modules/gtoken/build/src/index.js:232:31)
at GoogleToken.getTokenAsyncInner (node_modules/gtoken/build/src/index.js:166:21)
at GoogleToken.getTokenAsync (node_modules/gtoken/build/src/index.js:145:55)
at GoogleToken.getToken (node_modules/gtoken/build/src/index.js:97:21)
at …Run Code Online (Sandbox Code Playgroud) gmail.users.labels.list()功能.使用Google的Node.js API时,尝试发送电子邮件时出错.错误是:
{
"code": 403,
"errors": [{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}]
}
Run Code Online (Sandbox Code Playgroud)
fs.readFile(secretlocation, function processClientSecrets(err, content) {
if (err) {
console.log('Error loading client secret file: ' + err);
return;
}
authorize(JSON.parse(content), sendMessage);
});
function sendMessage(auth) {
var raw = makeBody('myrealmail@gmail.com', 'myrealmail@gmail.com', 'subject', 'message test');
gmail.users.messages.send({
auth: auth,
userId: 'me',
message: {
raw: raw
}
}, function(err, response) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过Google API发送电子邮件.
我在node.js中使用googleapis进行Google API访问.
我的问题是,当我尝试发送没有附件的简单邮件时,我收到以下错误:
'raw'RFC822有效负载消息字符串或通过/ upload/*URL上传消息
我没有在我的请求中定义有附件,我没有在电子邮件地址中看到任何错误.
请帮忙.
我的代码:
var google = require('googleapis');
var gmailClass = google.gmail('v1');
var email_lines = [];
email_lines.push("From: \"Some Name Here\" <rootyadaim@gmail.com>");
email_lines.push("To: hanochg@gmail.com");
email_lines.push('Content-type: text/html;charset=iso-8859-1');
email_lines.push('MIME-Version: 1.0');
email_lines.push("Subject: New future subject here");
email_lines.push("");
email_lines.push("And the body text goes here");
email_lines.push("<b>And the bold text goes here</b>");
var email =email_lines.join("\r\n").trim();
var base64EncodedEmail = new Buffer(email).toString('base64');
gmailClass.users.messages.send({
auth: OAuth2Client,
userId: "me",
message:
{
raw: base64EncodedEmail
}
},
function(err, results){});
Run Code Online (Sandbox Code Playgroud) 我想发展我的用户的应用内购买和订阅的服务器端验证的建议,我想用火力地堡功能为.基本上它必须是一个HTTP触发器函数,它接收购买令牌,调用Play Developer API来验证购买,然后对结果做一些事情.
但是,调用许多Google API(包括Play Developer API)需要进行非平凡的授权.以下是我理解所需设置的方法:
问题是绝对没有人类可读的文档或指导.鉴于Firebase中的入口流量包含在免费计划中(因此我假设他们鼓励使用Firebase功能中的Google API),这一事实非常令人失望.我已经设法在这里和那里找到一些信息,但是对于谷歌API的经验太少(大多数只需要使用api密钥),我需要帮助将它放在一起.
这是我到目前为止所发现的:
我很惊讶没有被询问或记录,因为从Firebase功能验证应用内购买似乎是一项常见任务.有没有人成功完成它,或者Firebase团队可能会介入回答?
google-api firebase google-api-nodejs-client google-play-developer-api google-cloud-functions
我有两个方法。
第一个读取文件并以纯文本形式写入该文件。第二个将文件作为流写入。
为了让它工作,我不得不在 require 中添加 fs 两次。
const fs = require('fs').promises;
const fs2 = require('fs');
Run Code Online (Sandbox Code Playgroud)
我试图理解其中的区别以及为什么我需要两次。但似乎没有promise的fs没有能力使用createWriteStream,而没有.promises的fs没有能力使用writeFile
/**
* Serializes credentials to a file compatible with GoogleAUth.fromJSON.
*
* @param {OAuth2Client} client
* @return {Promise<void>}
*/
async function saveCredentials(client) {
const content = await fs.readFile(CREDENTIALS_PATH);
const keys = JSON.parse(content);
const key = keys.installed || keys.web;
const payload = JSON.stringify({
type: 'authorized_user',
client_id: key.client_id,
client_secret: key.client_secret,
refresh_token: client.credentials.refresh_token,
});
await fs.writeFile(TOKEN_PATH, payload);
}
Run Code Online (Sandbox Code Playgroud)
第二个以流的形式写入文件
/**
* Download file
* …Run Code Online (Sandbox Code Playgroud) 我想使用Google的REST API访问公共日历.
Google的日历API建议我需要OAuth令牌才能访问日历:
https://developers.google.com/google-apps/calendar/auth
但是,我正在访问公共日历并且正在从服务器执行此操作,因此不能/不应该要求用户进行身份验证.
我正在使用node.js api:
googleapis
.discover('calendar', 'v3').execute(function(err, client) {
client.calendar.calendars.get({ calendarId: '***@group.calendar.google.com' })
.execute(function (err, response) {
console.log('response from google', response);
});
});
Run Code Online (Sandbox Code Playgroud)
这将返回"您的客户已发出格式错误或非法请求.这就是我们所知道的."
调用.withApiKey('***')后.calendars.get()返回相同的错误.
有什么建议?
google-calendar-api google-api node.js google-api-nodejs-client
我目前正在使用npm psi针对可公开访问的网站进行psi测试(基本身份验证除外).
到目前为止,我尝试使用用户名:password @ convention失败了我的psi和psi.
我想知道我是否遗漏了什么?
{ [Error: PageSpeed is currently unable to fetch this URL. Please try again later.] code: 400, noStack: true }
Run Code Online (Sandbox Code Playgroud) 我正在一个函数中创建一个oauth2client,并返回它.我实际上传递了clien id,secret,redirect url和凭据.根据我的检查,这些都是正确的.
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
...
credentials = {
access_token: accessToken,
refresh_token: refreshToken
};
oauth2Client.setCredentials(credentials);
Run Code Online (Sandbox Code Playgroud)
然后我在返回oauth2client对象的函数中执行此操作:
var plus = google.plus('v1');
console.log(JSON.stringify(oauth_client));
plus.people.get({ userId: 'me' , auth: oauth_client}, function(err, response) {
if(err) {
console.log(err);
} else {
console.log(JSON.stringify(response));
return response;
}
});
Run Code Online (Sandbox Code Playgroud)
但是,然后我收到一条错误消息,指出authClient.request不是函数.
TypeError:authClient.request不是createAPIRequest中的函数(/node_modules/googleapis/lib/apirequest.js:180:22)
我不确定为什么会出现这个错误.我也做了console.log(JSON.stringify(oauth_client))来检查请求函数,我没有看到任何.有人提到这不能显示完整的原型链,并且请求函数可能实际存在.
google-api node.js google-api-client meteor google-api-nodejs-client
我想获取从我的应用登录的用户的所有谷歌私人连接.我启用了Google People和Google Plus API.我设置了凭证API密钥,客户端ID和客户端密钥.我正在尝试获取用户连接的URL是
https://people.googleapis.com/v1/people/me/connections?fields=connections&key=api_key&access_token=access_token
Run Code Online (Sandbox Code Playgroud)
另外,我正在使用图书馆passport-google-oauth来获取用户access_token.以上网址中是否有任何我遗漏的内容.
我的谷歌验证码是
// send to google to do the authentication
// profile gets us their basic information including their name
// email gets their emails
app.get('/auth/google', passport.authenticate('google', {
scope: ['profile', 'email','https://www.googleapis.com/auth/contacts.readonly', 'https://www.googleapis.com/auth/contacts']
}));
// the callback after google has authenticated the user
app.get('/auth/google/callback',
passport.authenticate('google', {
successRedirect: '/profile',
failureRedirect: '/'
}));
Run Code Online (Sandbox Code Playgroud) google-api google-api-nodejs-client passport-google-oauth google-people
我正在尝试从我的节点服务器(作为Firebase云功能运行)连接到Google Analytics Reporting API v4.我想使用JWT进行身份验证,例如:http://nali.org/google-analytics-v4-api-node-js-starter-example/
但是我收到此错误:
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Sign.sign (crypto.js:307:26)
at Object.sign (/user_code/node_modules/googleapis/node_modules/jwa/index.js:76:45)
at Object.jwsSign [as sign] (/user_code/node_modules/googleapis/node_modules/jws/lib/sign-stream.js:32:24)
Run Code Online (Sandbox Code Playgroud)
它似乎试图使用PEM文件,但我只想使用电子邮件和私钥.这不可能吗?我给出的示例链接是误导性的吗?
这是我的代码:
const email = functions.config().ga.email;
const privateKey = functions.config().ga.privatekey;
const scope = ['https://www.googleapis.com/auth/analytics.readonly'];
const token = new googleapis.google.auth.JWT(email, null, privateKey, scope, null);
token.authorize( (error, tokens) => {
if (error) {
console.error('Error connecting to GA:', error);
} else {
console.log('Authorized!', tokens);
}
})
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
google-api node.js google-api-nodejs-client google-analytics-firebase