Google Meteor 中的 Oauth 流程

Google Oauth flow in Meteor

在 Meteor 应用程序中,谁能指导我如何让用户简单地进行 Oauth Google?

有 accounts-google 包,但我不希望用户能够使用它登录,只是 oauth 和存储凭据。

文档提到了 "If you just want to authenticate to an Oauth service like Twitter, Facebook, or Google without using Accounts – that is, if you don't want to log the user in, you just want an OAuth token – you can use the underlying service packages such as twitter, facebook, and google directly.",但是 google 包没有任何文档。

任何指导将不胜感激。

Oauth 的包就是为了做到这一点。如果你想用它来获取人们的凭证

有两种选择:

1) 修改 google 和 accounts-google 包的源以删除登录的部分。恐怕没有文档,最好理解是行内注释。

2) 使用另一个大气包将帐户-google 与现有登录合并。因此他们已经登录,但可以使用 Meteor.logInWithGoogle() 和 google 登录,这将与他们现有的帐户合并。这样他们就不必使用 Google 登录,但您可以存储 OAuth 令牌。为此,您可以使用 bozhao:link-accounts 包或 mikael:accounts-merge 包:

// ON THE CLIENT:
Meteor.signInWithGoogle ({}, function (error, mergedUserId) {

  // mergedUsers is set if a merge occured
  if (mergedUserId) {
    console.log(mergedUserId, 'merged with', Meteor.userId());
  }
});

然后您会在现有 Meteor.user() 文档的 services.google 中找到 google OAuth 令牌数据。

手动处理 Google OAuth 相当简单。检查我对这个(类似的)SO 问题的回答

Getting OAuth tokens without user registration