Sign in with Apple
Sign in with Apple is implemented as an external identity provider. The Onegini SDK allows you to implement it with minimal effort. It requires only configuring the project, selecting an identity provider with Apple ID and handling registration just like for browser based identity providers. All of the calls to AuthorizationServices framework will be made by the SDK.
Configuring the project
To configure the project, please follow steps mentioned here: https://developer.apple.com/documentation/authenticationservices/adding_the_sign_in_with_apple_flow_to_your_app
Perform the following steps before building and running the app:
- Set your development team in the Signing & Capabilities tab so Xcode can create a provisioning profile that uses the Sign In with Apple capability.
- Choose a target device that you’re signed into with an Apple ID that uses Two-Factor Authentication.
Initiating Registration
Identity Provider supporting Apple ID can be picked by fetching Identity Providers set and selecting the an object with ONGExternalIdpAppleType
value under the externalIdentityProvider.type
property.
NSSet <ONGIdentityProviders *> *identityProviders = [ONGUserClient sharedInstance].identityProviders;
ONGIdentityProvider *appleIdentityProvider = [identityProviders filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"externalIdentityProvider.type == %@", ONGExternalIdpAppleType]].anyObject;
[[ONGUserClient sharedInstance] registerUserWithIdentityProvider:appleIdentityProvider scopes:yourScopes delegate:self];
The Onegini SDK will perform Sign in with Apple ID
using Authorization Services framework after you call -[ONGUserClient registerUserWithIdentityProvider:scopes:delegate:]
method. The
native popup will be shown to the user. After successful authentication the SDK will send browser registration challenge that needs to be handled.
Handling Registration
The user registration with Apple ID is handled the same way as browser based identity providers. Please refer to Handling Browser Registration Challenge topic guide for more info.