[英]Google sign-in inside Node.js script
I want to integrate google sign-in in my Node.js script so I can log who used that script.我想在我的 Node.js 脚本中集成谷歌登录,这样我就可以记录谁使用了该脚本。
I am able to add google sign-in in webpage with help of https://developers.google.com/identity/sign-in/web/sign-in but could not find way to add google sign-in in standlaone script.我可以在https://developers.google.com/identity/sign-in/web/sign-in的帮助下在网页中添加谷歌登录,但找不到在独立脚本中添加谷歌登录的方法。
Let me try explain my intention让我试着解释一下我的意图
var googleSignIn = async function () {
// sign in using google account and return email addess on succesfull sign in
}
var work = async function () {
// step 1: log in first using google
var email = await googleSignIn()
// step 2: talk to backed server api on succesfull login
if (email) {
console.log('calling backend api')
} else {
console.log('you need to login first')
}
}
work().then(function () {
console.log('done')
}).catch(function (error) {
throw error
})
I want to implement googleSignIn
method.我想实现
googleSignIn
方法。 How can I do that?我怎样才能做到这一点?
Your script would need to operate in the same manner as a desktop app, and perform these actions:您的脚本需要以与桌面应用程序相同的方式运行,并执行以下操作:
A typical URL would be a value like this:典型的 URL 将是这样的值:
https://accounts.google.com/oauth2/v2.0/authorize?
client_id=y792f434f
&response_type=code
&redirect_uri=com.mycompany.myapp:/callback
&scope=...
&state=...
&code_challenge=...
&code_challenge_method=S256
It is a tricky flow to implement though - in case useful there are further details in my Desktop OAuth Blog Posts , and code samples you can run...虽然这是一个棘手的流程 - 如果有用,我的桌面 OAuth 博客帖子中有更多详细信息,您可以运行代码示例......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.