我正在尝试从我的节点服务器(作为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
有没有办法通过Firebase Phone Auth禁用Android"即时验证"(自动登录)?有一种方法可以通过将verifyPhoneNumber的超时设置为0来禁用"自动检索"(参考:https://firebase.google.com/docs/reference/android/com/google/firebase/auth/PhoneAuthProvider.html ) .但是,我找不到一种记录的方法来禁用即时验证.
我问的是因为潜在的安全问题:从设备中取出SIM卡仍会自动登录该用户!换句话说,使用其他人的旧设备的用户可以使用他们的旧电话号码登录.以下是复制步骤:
观察到的行为:尽管没有相应的SIM卡,用户仍会自动登录
预期行为:如果用户的设备没有与输入的电话号码关联的SIM卡,则它们不会自动登录,并且会向该号码发送SMS文本消息.