Set up Apple as an identity provider
Overview
You can connect your verified Apple Developer account to AccelByte Gaming Services (AGS) to enable Apple authentication in your game with the AGS SDK and in your publisher website with the AGS Player Portal. You may need to set up additional features within Apple services that are not listed here. We recommend contacting your Apple representative and reviewing the Apple Developer documentation.
This guide is intended for public use and contains limited information due to confidentiality. We recommend you refer to the full confidential guide first. Contact your AccelByte Technical Producer to request a copy of the guide.
Prerequisites
The prerequisites for enabling Apple as an identity provider vary as follows:
Web login integration
To set up web login integration, you must have:
- An Apple Developer account.
- An AGS Admin Portal account to set up authentication and manage permissions.
- A publisher namespace for your Player Portal and Launcher.
- A Player Portal.
In-game login integration
To set up in-game login integration, you must have:
- An Apple Developer account.
- A Unity or Unreal game project with the latest version of the AccelByte Game SDK imported.
- For Unreal Engine, you need
OnlineSubsystemApple
(Apple OSS). - For Unity, you need the AccelByte Apple Unity SDK.
- An AGS Admin Portal account to set up authentication and manage permissions.
- A game namespace.
- Familiarity with AGS Identity and Access Management (IAM) Clients.
Set up Apple configuration
To enable Apple as an identity provider, follow these steps first in your Apple Developer account.
Create certificates
The certificates resource represents the digital certificates you use to sign in to your iOS or Mac, or web apps for development and distribution. You must create a Developer ID application certificate. To do this, follow the steps on the Create Certificate guide in the Apple Developer documentation.
Only the appropriate account holder, manager, or admin can create certificates.
Create App IDs
An App ID identifies your app in a provisioning profile. It is a two-part string used to identify one or more apps from a single development team. You must create App IDs with App Type. To do this, follow the steps on the Register an App ID guide in the Apple Developer Documentation.
Only the appropriate account holder, admin, or other accounts with relevant permissions can create an app.
Create Service ID
For each website that uses Sign in with Apple (SIWA), it's necessary to register a services identifier (Services ID). Configure your domain and return URL, then create an associated private key. To do this, follow the steps on the Configure Sign in with Apple for the web guide in the Apple Developer documentation.
Create key
Enable your apps to allow users to authenticate in your application with their Apple ID. To do this, follow the steps on the Create a private key to access a service guide in the Apple Developer Documentation. Ensure that you keep a copy of the key you generate in this step. You will need it when you set up the Apple login method for web and in-game.
The SIWA feature must be enabled to be able to create keys.
Set up Apple login method
Set up web login
To allow your players to sign in to your Player Portal using their Apple accounts, follow these steps:
In the AGS Admin portal, go to your publisher namespace.
On the sidebar menu, go to Game Setup > 3rd Party Configuration > Auth & Account Linking.
On the Login Methods page, click on the + Add New button.
From the list of login method options, select Apple and fill in the login configuration with your Apple credentials. Click Create when you're done.
- Service ID: Your Apple Service ID.
- Private Key: The base64-encoded string of your Private Key. To obtain it, you'll need to convert the entire
.p8
file that you downloaded when you created your key into a base64 string. You can use your preferred converter. - Team ID: Your Apple Team ID. You can find it under your account name in the Apple Developer console.
- Key ID: Your key you generated from the Create key step.
On the details page, click Activate, then click Activate on the pop-up to confirm.
Test and verify
After activating the Apple web login method, you can test it out on your Player Portal. Follow these steps:
Go to the login page of your Player Portal.
From the login options, select the Apple logo.
You will be redirected to the Apple Login page. Use your Apple credentials to log in.
noteCurrently, the system asks players to link their Apple account with an existing or new AccelByte account. AccelByte is working on the ability to enable players to log in to the Player Portal with a headless account.
Set up in-game login
To allow your players to sign in to your game using their Apple accounts, follow these steps:
- In the AGS Admin portal, go to your game namespace.
On the sidebar menu, go to Game Setup > 3rd Party Configuration > Auth & Account Linking.
On the Login Methods page, click on the + Add New button.
From the list of login method options, select Apple and fill in the login configuration with your Apple credentials. Click Create when you're done.
- Service ID: Your Apple Service ID.
- Private Key: The base64-encoded string of your Private Key. To obtain it, you'll need to convert the entire
.p8
file that you downloaded when you created your key into a base64 string. You can use your preferred converter. - Team ID: Your Apple Team ID. You can find it under your account name in the Apple Developer console.
- Key ID: Your key you generated from the Create key step.
On the details page, click Activate, then click Activate on the pop-up to confirm.
Create an IAM client for Apple
An IAM client is a representation of the game client that you want to release on your target platform. Learn more about IAM Clients in Manage access control for applications.
In-game login
The setup for each game engine is different. Follow the steps that are applicable to your game engine.
- Unreal Engine instructions
- Unity Engine Instructions
Unreal Engine in-game login integration
Prepare Unreal project settings
Set the Client ID and Client Secret in DefaultEngine.ini file.
[/Script/AccelByteUe4Sdk.AccelByteSettings]
ClientId=abcdefg12345
ClientSecret=abcdefg12345
Namespace=test
PublisherNamespace=accelbyte
BaseUrl="https://prod.gamingservices.accelbyte.io"
QosPingTimeout=0.6
[/Script/AccelByteUe4Sdk.AccelByteServerSettings]
ClientId=defghi12345
ClientSecret=defghi12345
Namespace=test
PublisherNamespace=accelbyte
RedirectURI="http://127.0.0.1"
BaseUrl="https://prod.gamingservices.accelbyte.io"
QosPingTimeout=0.6Set these fields in the
IOSGame.ini
file.[OnlineSubsystem]
; For iOS, our native service will be IOS
DefaultPlatformService=IOS
NativePlatformService=Apple
[OnlineSubsystemApple]
bEnabled=True
[OnlineSubsystemIOS]
bEnabled=True
[OnlineSubsystemIOS.Store]
bSupportsInAppPurchasing=True
bUseStoreV2=false
[/Script/IOSRuntimeSettings.IOSRuntimeSettings]
bEnableSignInWithAppleSupport=True
[OnlineSubsystemGoogle.OnlineIdentityApple]
+ScopeFields="email"
+ScopeFields="fullName"Add the
AccelByteUe4Sdk
plugin name into theBuild.cs
file.PublicDependencyModuleNames.AddRange(new string[] { "AccelByteUe4Sdk" });
PrivateDependencyModuleNames.Add("OnlineSubsystem");
PrivateDependencyModuleNames.Add("OnlineSubsystemAccelByte");
PrivateDependencyModuleNames.Add("OnlineSubsystemApple");Enable
OnlineSubsystemApple
plugin in your project's.uproject
file.{
"Name": "OnlineSubsystemApple",
"Enabled": true,
"SupportedTargetPlatforms": [
"Mac",
"IOS",
"TVOS"
]
},
Unreal Engine IOS build configuration
Set the Unreal certificates and provisioning
Set the Bundle Identifier to your app's Bundle ID from the Apple Developer portal. Make sure the App ID already has SIWA capability.
Set the correct certificate and provisioning file. This requires
.mobileprovision
andcert.SingningRequest
files.Ensure the Signing & Capabilities on your local setup (Xcode) has the Sign In with Apple capability enabled.
Unreal Engine Source BaseEngine.ini
Configuration to Enable SIWA
Locate the file
[EngineDir]/Config/BaseEngine.ini
in the Engine installation.Open it and search for
[/Script/IOSRuntimeSettings.IOSRuntimeSettings]
section.Add this field under that section.
[/Script/IOSRuntimeSettings.IOSRuntimeSettings]
bEnableSignInWithAppleSupport=True <--- Please add this boolean configuration
Unreal Engine Source Code Modification to using AuthorizationCode Instead of IdentityToken
Avoid this modification completely if there is no particular reason to use AuthorizationCode
and we not recommend it.
Our Identity service already recognizes IdentityToken
and the Unreal Engine Apple Subsystem also automatically supports IdentityToken
. We can discard the AuthorizationCode
flow.
To forcefully change the IdentityToken
generation into AuthorizationCode
. We need to follow these steps:
Locate and open the following file.
<EngineDir>\Plugins\Online\OnlineSubsystemApple\Source\Private\OnlineExternalUIInterfaceApple.cpp
Inside the file, locate this line.
signInWithAppleBridge->SignInResultCallback([AuthAppleID user], [AuthAppleID identityToken], [AuthAppleID email], [AuthAppleID fullName], nullptr);
Change the line to the following, replacing the information in the square brackets appropriately.
signInWithAppleBridge->SignInResultCallback([AuthAppleID user], [AuthAppleID authorizationCode], [AuthAppleID email], [AuthAppleID fullName], nullptr);
Unreal sample code implementation
Header declaration:
#include <OnlineSubsystem.h>
#include "Interfaces/OnlineIdentityInterface.h"
#include "Interfaces/OnlineLeaderboardInterface.h"
#include "OnlineIdentityInterfaceAccelByte.h"
#include "OnlineSubsystemAccelByte.h"
#include "OnlineSubsystemAccelByteTypes.h"
#include "Core/AccelByteMultiRegistry.h"
#include "Core/AccelByteError.h"Log in to Apple Service using Apple OnlineSubsystem, then get the
PlatformToken
fromOnlineIdentity->GetAuthToken(...)
.const IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get(TEXT("Apple"));
if (OnlineSubsystem == nullptr)
{
FString Message = TEXT("Cannot login with no online subsystem set!");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
const IOnlineIdentityPtr OnlineIdentity = OnlineSubsystem->GetIdentityInterface();
if (!OnlineIdentity.IsValid())
{
FString Message = TEXT("Could not retrieve identity interface from native subsystem.");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
int32 TempLocalUserNum = 0;
OnlineIdentity->AddOnLoginCompleteDelegate_Handle(TempLocalUserNum,
FOnLoginCompleteDelegate::CreateLambda([=]
(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error)
{
if (bWasSuccessful)
{
UE_LOG(LogTemp, Warning, TEXT("Success Apple Login"));
PlatformToken = OnlineIdentity->GetAuthToken(TempLocalUserNum);
UE_LOG(LogTemp, Warning, TEXT("Apple PlatformToken : %s"), *PlatformToken);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Error Login: %s"), *Error);
}
})
);
// login native
FOnlineAccountCredentials Creds{};
OnlineIdentity->Login(TempLocalUserNum, Creds); // Apple LoginLog in to AGS using AGS Online Subsystem (OSS) or AGS SDK.
- AGS OSS
- AGS SDK
The login success indicator can be confirmed by the
bWasSuccessful
boolean from theFOnLoginCompleteDelegate
callback.// Log in to AGS using OSS
const IOnlineSubsystem* OnlineSubsystemABPtr = IOnlineSubsystem::Get("ACCELBYTE");
if (OnlineSubsystemABPtr == nullptr)
{
FString Message = TEXT("Cannot login to AGS, AccelByte Online Subsystem is null!");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
const IOnlineIdentityPtr OnlineIdentityABPtr = OnlineSubsystemABPtr->GetIdentityInterface();
if (OnlineIdentityABPtr == nullptr)
{
FString Message = TEXT("Cannot login to AGS, AccelByte Identity Interface is null!");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
bool bABLoginDone = false;
bool bABLoginSuccess = false;
FDelegateHandle ABOnLoginCompleteDelegateHandle;
const FOnLoginCompleteDelegate ABLoginComplete = FOnLoginCompleteDelegate::CreateLambda(
[&]
(int32 LoggedInLocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, FString Error)
{
bABLoginDone = true;
bABLoginSuccess = bWasSuccessful;
if (bWasSuccessful)
{
UE_LOG(LogTemp, Log, TEXT("Log in to AGS result: success."));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Log in to AGS result: fail."));
}
OnlineIdentityABPtr->ClearOnLoginCompleteDelegate_Handle(0, ABOnLoginCompleteDelegateHandle);
});
ABOnLoginCompleteDelegateHandle = OnlineIdentityABPtr->AddOnLoginCompleteDelegate_Handle(0, ABLoginComplete);
FOnlineAccelByteAccountCredentials OnlineAccountCredentialsNative(
EAccelByteLoginType::Apple,
"",
PlatformToken, // Obtained from previous step; log in using Apple OnlineSubsystem
true);
OnlineIdentityABPtr->Login(0, OnlineAccountCredentialsNative);noteWe don't recommend this method. However, if you prefer to log in using the AGS SDK, take note that the SDK may not be able to support various functions such as handling player states, caching mechanisms, native-platform functions, etc.
// Log in to AGS using low-level SDK
FRegistry::User.LoginWithOtherPlatform(EAccelBytePlatformType::Apple
, PlatformToken //Obtained from previous step, Log in using Apple OnlineSubsystem
, FVoidHandler::CreateLambda([=]()
{
UE_LOG(LogTemp, Log, TEXT(" Success AB Login "));
})
, FOAuthErrorHandler::CreateLambda([=](int32, const FString&, const FErrorOAuthInfo& Result)
{
UE_LOG(LogTemp, Warning, TEXT(" Error. Code: %s, Reason: %s"), *Result.Error, *Result.Error_description);
}));
Sample code testing
Old sample using AuthorizationCode
This example shows the result of testing the code using iPhone 11. The following image shows that the code works and a user is able to log in using Apple with the sample code.
Recent sample using IdentityToken
This example shows the result of testing the code using iPhone 14. The following image shows the Apple IdentityToken
from Unreal Engine Apple Online Subsystem.
The token is exchanged to AGS and we can obtain the AccelByte authorization token (LoginToIAM result).
Unity in-game login integration
Prepare Unity project settings
In the SDK Config, fill in each attribute based on the AGS Admin Portal values and save the configuration. For more information, see Install and configure the SDK.
Unity build configuration
Set the Certificate and Provisioning
Set the Bundle Identifier to your app's Bundle ID from the Apple Developer portal. Make sure the App ID already has SIWA capability.
Go to Project Settings > Player > iOS > Other Settings. Then, do th following:
- Check the Override Default Bundle Identifier box and add your Bundle ID from the Apple Developer Portal.
- Check the iOS Provisioning Profile box and add your Profile ID from the certificate that you created from the Create certificates step.
Install AccelByte Apple Unity SDK
The AccelByte Unity SDK Apple Games extension enables you to integrate Apple's features with AGS. You can find and download this extension on GitHub. To install the extension and implement Google login into your game, follow the extension's installation guide on GitHub.