# Sign in with Apple
# Prerequisites
You need to prepare the following in total:
- Register a developer account at Apple Developer (opens new window).
- Register your iOS app on the Apple Developer Portal, please record the following ID and Key:
Bundle ID
,Apple Team ID
,Key ID
,Signing Key
, then you need to fill in the Authing console form. - Configure Sign in with Apple Social Connection in Authing Console
# Configure Sign in with Apple social connection in the Authing console
In the Authing console Connect Identity Source -> Social Login page, find Sign in with Apple in Mobile Login:
Please fill in Bundle ID
, Apple Team ID
, Key ID
and Signing Key
respectively:
Click the Save button.
# API Refrence
Here we recommend reading the official guidelines provided by Apple: Implementing User Authentication with Sign in with Apple (opens new window), download the sample Demo program:
Please make sure that the Bundle ID and the application you created in Apple Developer (opens new window) Bundle ID (For details, please see: Register your iOS application) consistent:
# Get authorizationCode
Modify the authorizationController
method in LoginViewController.swift
, you can get the authorizationCode
in appleIDCredential
, and use the authorizationCode
to exchange user information:
if let authorizationCode = String(bytes: appleIDCredential.authorizationCode!, encoding: .utf8) {
print("authorizationCode")
print(authorizationCode)
} else {
print("not a valid UTF-8 sequence")
}
# Exchange for user information
After getting the authorizationCode
, you can call the Authing interface in exchange for the user's information:
Use authorizationCode in exchange for user information.
# Next
After obtaining the user information, you can get the login credential token. You can carry this token in subsequent API requests, and then distinguish different users based on this token in the backend interface. For details, see [Verification token](../ ../advanced/verify-jwt-token.md#yan-zheng-authing-qian-fa-de-token).