流星 loginWithApple oauth - "Service not configured"

Meteor loginWithApple oauth - "Service not configured"

我正在添加 Apple 登录,最新的 oauth 包加入 Meteor,但是我 运行 进入错误消息 “服务未配置”。似乎很多 solutions [] 都在谈论使用 ServiceConfiguration 来修复这些错误,但我不必初始化任何其他流星登录,例如 loginWithGoogleloginWithFacebook。根据我对 github 包的阅读,Meteor.loginWithApple 的配置方式与这些现有的登录功能相同。什么配置问题可能会触发此问题?

当我查看 Meteor.settings.private.oAuth 时,apple 就在 googlefacebook 旁边。

首先我安装了这两个https://atmospherejs.com/quave/accounts-apple, https://atmospherejs.com/quave/apple-oauth

meteor add quave:accounts-apple
meteor add quave:apple-oauth

然后在 settings.json 中设置 config 以及 facebook 和 google oauth guide.

settings.json:

"apple": {
  "teamId": "yyexamplexx",
  "clientId": "com.example.client",
  "keyId": "zzexamplewq",
  "secret": "zxcvsdfasdfexamplezlongstrxcvsdfasdf",
  "redirectUri": "https://example.com/apple-redirect"
},

客户:

continueWithApple = () => {
  Meteor.loginWithApple({}, function(err, res) {
    if (err) {
      console.log(err);
    }
    //running ok
  });
};

<Form.Button
  id="appleid-signin"
  fluid
  basic
  className="continue apple"
  data-color="black"
  data-border="true"
  data-type="sign in"
  onClick={() => {
    this.continueWithApple();
  }}
>

出于某种原因,配置 oauth 设置未被传递,因此我们必须执行类似以下操作以设置凭据并停止“服务未配置”错误消息:

Meteor.startup(() => {

  // remove any existing service so you can configure the latest one
  Accounts.loginServiceConfiguration.remove({ service: "apple" });
  // setup apple login, drawing from your settings.json
  Accounts.loginServiceConfiguration.insert(Meteor.settings.private.oAuth.apple);

...

)}

我们的配置类似于:

  "private": {
    "oAuth": {
      "apple": {
        "secret": "-----BEGIN PRIVATE KEY-----\nxyzexamplexyz\n-----END PRIVATE KEY-----",
        "redirectUri": "https://www.example.com/_oauth/apple",
        "clientId": "com.example.client",
        "teamId": "WXYZ8EXAMPLE",
        "keyId": "456EXAMPLE",
        "scope": "name%20email",
        "responseMode": "form_post",
        "responseType": "code",
        "service": "apple"
      }

似乎 important redirectUri_oauth/apple 结尾,因为流星的 loginWithApple 正在寻找它。根本不需要处理回调,下面的包会处理它。

meteor add quave:accounts-apple
meteor add quave:apple-oauth

%20 放在范围 name%20email 中也很重要...它 just worked.