注意!本文是app授权 不是web授权 确认后再往下看 避免浪费时间
准备功能所需的物料
关于在苹果开发者网站上创建app、创建server id和创建密钥
这位同学总结的很好 直接看:juejin.cn/post/684490...
我们需要的三个东西:
1、这里的Identifier

2、进入后填写的Return URLs

3、密钥文件 .p8结尾的文件

准备好后 开始写代码------前端
一、下载capacitor插件
npm i @capacitor-community/apple-sign-in"
二、使用插件唤起苹果授权
            
            
              javascript
              
              
            
          
              const options: SignInWithAppleOptions = {
      clientId: "xxxxx", (填刚刚的Identifier)
      redirectURI: "https://xxxx/redirect",(填刚刚的Return URLs)
      scopes: "email name",
      state: "12345",
      nonce: "nonce",
    };
    SignInWithApple.authorize(options)
      .then((result: SignInWithAppleResponse) => {
        if (result) {
          //这里的result.response.identityToken作为参数给后端
          //拿着参数请求接口
        }
      })
      .catch((error) => {}
      });(前端测试的时候注意:macWeb上授权了也没有result 得在ios设备去操作)
三、把.p8结尾的文件发给后端
接下来是接口------后端
我们是app授权所以用JWT, web授权才用OAuth
参考文章:www.cnblogs.com/jice/p/1634...
总流程:
