1

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

当我看的时候Meteor.settings.private.oAuthapple就在google旁边facebook

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

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

然后按照本指南configsettings.jsonfacebook 和 google 旁边设置。oauth

设置.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();
  }}
>
4

1 回答 1

0

由于某种原因,配置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"
      }

由于流星正在寻找它,因此结尾似乎很重要。根本不需要处理回调,下面的包会处理它。redirectUri_oauth/appleloginWithApple

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

%20将其放入范围也很重要name%20email......它刚刚起作用

于 2020-07-28T14:47:00.127 回答