gpt4 book ai didi

node.js - 在Azure webapp服务器中获取Google Plus用户access_token

转载 作者:行者123 更新时间:2023-12-03 05:58:28 25 4
gpt4 key购买 nike

我已经设置了一个使用 Express 成功运行 Node.JS 的 Azure Web 应用程序,并使用内置的 Azure Google“身份验证/授权”添加了 Google Plus 身份验证。身份验证过程使用 SSL 运行得很好,并且我能够对用户进行身份验证。

现在,我知道身份验证过程正在调用 https://mysite.azurewebsites.net/.auth/login/google/callback使用用户 access_token 进行将来的 API 调用,但在这种情况下,Azure 会“拦截”它(而不是通常发生的情况 - 我会在我的服务器上获取它)。

问题是 - 为什么要在服务器上获取和使用此 token ?

我尝试添加一条到 .auth/login/google/callback 的路由,并且有人获取了代码

router.get('/.auth/login/google/callback', function (req, res, next) {
console.log("CALLBACK");
next();
});

没用...

最佳答案

来自 google+ 的身份验证信息将设置在请求 header 中。如果您在路由器函数中列出请求 header ,例如:res.send(JSON.stringify(req.headers));

您可以在带有前缀 x-ms-token-google- 的 header 中设置身份验证信息。

引用https://azure.microsoft.com/en-us/documentation/articles/app-service-api-authentication/了解更多详情。

同时,您只需向站点上的/.auth/me 端点发出 GET 即可检索其他用户信息以及图形调用所需的任何 token 。引用https://azure.microsoft.com/en-us/blog/announcing-app-service-authentication-authorization/了解详情。

关于node.js - 在Azure webapp服务器中获取Google Plus用户access_token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36730852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com