简体   繁体   中英

Meteor loginWithApple oauth - “Service not configured”

I'm adding Apple login, the latest oauth package to join Meteor, but I'm running into the error message "Service not configured" . It seems that a lot of the solutions [ another ] talk about using ServiceConfiguration to fix these errors, but I haven't had to initialize any of the other meteor logins such as loginWithGoogle or loginWithFacebook . Based on my reading through the github package Meteor.loginWithApple is configured the same way as these existing login functions. What configuration issue might be triggering this?

When I look at Meteor.settings.private.oAuth , apple is right there alongside google and facebook .

First, I installed these two https://atmospherejs.com/quave/accounts-apple , https://atmospherejs.com/quave/apple-oauth

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

Then set up the config in settings.json alongside facebook and google oauth per this guide .

settings.json :

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

Client :

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();
  }}
>

For some reason the config oauth settings aren't being passed on, so we had to do something like the following in order to set up the credentials and stop the "Service not configured" error message:

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);

...

)}

Our configuration looked something like:

  "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"
      }

It seems to be important that the redirectUri ends with _oauth/apple since meteor's loginWithApple is looking for that. Didn't need to handle the callback at all, the packages below take care of it.

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

Also important to put the %20 in the scope name%20email ...it just worked .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM