gpt4 book ai didi

angularjs - 如何在 postgresql 中存储 Oauth 响应?

转载 作者:行者123 更新时间:2023-11-29 11:36:51 25 4
gpt4 key购买 nike

我正在为我的应用程序使用带 Angular js(前端)和 postgresql(数据库)的环回框架(Node.js),在我的应用程序中,我使用了第三方登录“passport-google-oauth”。

google auth 后,回调 url 返回如下代码的响应。

例如:http://localhost:3000/gauthServer

文件:routes.js

app.get('/gauthServer', function(req, res) {
console.log(req.cookies.currentUserEmail);
console.log(req.cookies.currentUsername);
console.log(req.cookies.currentUserId);
console.log(req.cookies.accessToken);
//res.redirect("/");
});

在上面的代码中,它正确地返回了我在 console.log() 中打印的响应。

预期结果:我希望将上述结果存储在 postgresql 数据库中。

最佳答案

答案很简单,但过于宽泛。

基本上你要做的是:

  1. 使用 slc loopback:datasource command 创建数据源并选择 postgresql 连接器
  2. 执行 npm i loopback-connector-postgresql --save
  3. 使用slc loopback:model command创建将包含上述属性的模型并将其连接到数据库。向导将再次帮助您这样做。
  4. 使用 create method 将数据保存到数据库中在你的模型上

您还可以找到 this answer有用。

关于angularjs - 如何在 postgresql 中存储 Oauth 响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35450536/

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