Skip to content
LogoLogo

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

  1. In the Openfort Dashboard, navigate to the Providers Connections page.
  2. Select Add connection and select For all users.
  3. In the Choose provider dropdown, select Apple.
  4. Ensure that Enable for sign-up and sign-in is toggled on.

Add the Sign in with Apple capability to your app

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 AppleAuthManager class.
  • 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
}