Sign in with Apple
This guide will teach you how to add native Sign in with Apple to your Openfort apps on Apple platforms.
Add your Native Application
Add your iOS application to the Users page in the Openfort dashboard. You will need your iOS app's App ID Prefix and Bundle ID.
Enable Apple as a social connection
- In the Openfort Dashboard, navigate to the Providers Connections page.
- Select Add connection and select For all users.
- In the Choose provider dropdown, select Apple.
- Ensure that Enable for sign-up and sign-in is toggled on.
Obtain an Apple ID Credential
To authenticate with Apple and Openfort, you need to obtain an Apple ID Credential.
To obtain an Apple ID Credential, you can do one of the following:
- Use one of Apple's built-in Sign in with Apple buttons.
-Use Openfort's
AppleAuthManagerclass. - Obtain it manually by following the Apple docs.
Build your sign-in flow
Once you have obtained your Apple ID Credential, you can use it to authenticate with Openfort by calling OFSDK.shared.loginWithIdToken(params: OFLoginWithIdTokenParams(provider: OFAuthProvider.apple.rawValue, token: idToken)) with a provider of .apple and the idToken you have obtained.
The following example uses Apple's built-in SignInWithAppleButton to obtain an Apple ID Credential and calls OFSDK.shared.loginWithIdToken(params: OFLoginWithIdTokenParams(provider: OFAuthProvider.apple.rawValue, token: idToken)) to authenticate with Openfort.
Usage
let result = try await OFSDK.shared.loginWithIdToken(params: OFLoginWithIdTokenParams(provider: OFAuthProvider.apple.rawValue, token: idToken))Parameters
struct OFLoginWithIdTokenParams: OFCodableSendable {
public let provider: String
public let token: String
public let ecosystemGame: String?
}Returns
struct OFLoginWithIdTokenResponse: OFLoginWithIdTokenResponseProtocol, OFCodableSendable {
public let player: OFAuthPlayerResponse
public let token: String
public let refreshToken: String
}Throws
{
method: method,
success: false,
error: error
}