【三方登录-Apple】iOS 苹果授权登录(sign in with Apple)之开发者配置一

记录一下sign in with Apple的开发者配置

前言

关于使用 Apple 登录 使用“通过 Apple 登录”可让用户设置帐户并使用其Apple ID登录您的应用程序和关联网站。首先使用“使用
Apple 登录”功能启用应用程序的App ID 。 如果您是首次启用应用程序 ID 或为新应用程序启用应用程序 ID,请启用该应用程序
ID 作为主要应用程序 ID。您可以单独使用主应用程序 ID,也可以通过分组为相关应用程序和网站启用标识符。 要为相关应用程序启用应用程序
ID(例如,Mac 应用程序的 iOS 版本的应用程序 ID),请将其与现有主应用程序分组。如果您的应用程序具有适用于多个 Apple
平台或您想要启用“使用 Apple 登录”功能的 Web 的版本,这会很有帮助。通过与现有主标识符分组而启用的应用程序 ID
不能用于通过分组启用其他标识符。您需要取消应用程序 ID 的分组并将其启用为主要应用程序 ID。
您可以通过在证书、标识符和配置文件中编辑应用程序 ID 配置来管理应用程序 ID 。
在这里插入图片描述

一、配置Sign in with Apple

1.找到证书

在这里插入图片描述

2.创建新 app(web已有做关联) 并开启 Sign in with Apple

在这里插入图片描述

3.接下来新建一个新的 identifier,注意是 Services IDs

  • 1、创建 Identifiers

  • 2、选择 Services IDs 并点击右上角 Continue

  • 3、按下图顺序操作
    在这里插入图片描述在这里插入图片描述

4.接下来在Configure 配置回调地址

在这里插入图片描述

确保 Primary App ID 是你要选用的app
注意回调地址那里的链接必须要有 https 开头

5.设置完成,页面显示无误后可以选取左边的 Key

  1. 创建keyId

  2. 先选这个key关联到你的主app,然后点击continue,
    在这里插入图片描述

  3. 获取keyid
    在这里插入图片描述

怎么找到Sign in with Apple 回调地址?

1.Certificates, Identifiers & Profiles->Identifiers->右侧搜索筛选Services IDs

在这里插入图片描述

在这里插入图片描述

现在,你获得了 service ID, redirect URL, team ID, key ID, and private key. 接下来就可以开始第二部分 Sign In with Apple REST API.

clientId 是申请的serveic IDs 中的那个 identifier

6.网页前端配置

<button id="sign-in-with-apple-button"> Sign In with Apple </button>
<script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script>
<script type="text/javascript">
    AppleID.auth.init({
    
    
        clientId : 'xxxx',
        scope : 'email',
        redirectURI: 'https://dogfightx.com/',
        state : 'DE'
    });

    const buttonElement = document.getElementById('sign-in-with-apple-button');
    buttonElement.addEventListener('click', () => {
    
    
        AppleID.auth.signIn();
    });
</script>

猜你喜欢

转载自blog.csdn.net/qq_41791705/article/details/134137139