Web
This article guides you through setting up Apple as an identity provider, enabling your iOS game to access Player Network authentication services.
Prerequisites
1. Set up the Apple app on the Apple Developer Platform
1. Create a Service ID for web login
Log in to the Apple Developer Platform.
In the sidebar, click Certificates, IDs & Profiles.
In the sidebar, click Identifiers and click the blue add icon (+).
Select Services IDs and click Continue.
Enter the Description and Identifier.
- Description: The name or description of the game app displayed during user login
- Identifier: The unique identifier for web.
Under Capabilities, select the checkbox next to Sign in with Apple, and click Configure.
Under Return URLs, enter the redirect link provided by Player Network.
- North America: https://na-webproxy.intlgame.com/v2/webproxy/appleredirect
- Singapore and other regions: https://sg-webproxy.intlgame.com/v2/webproxy/appleredirect
- Testing: https://test-webproxy.intlgame.com/v2/webproxy/appleredirect
- aws-North America: https://aws-na-webproxy.intlgame.com/v2/webproxy/appleredirect
Click Save and then click Continue and Register to create a Service ID for web login.
2. Create a key to access enabled capabilities
In Certificates, IDs & Profiles, click Keys in the sidebar.
Click the the blue add icon (+).
Under Key Name, enter a unique name for the key.
Select the checkbox next to Sign in with Apple, and click Configure.
Under Primary App ID, select the Service ID created in Step 1 and click Save.
Click Continue.
Click Register to generate the key, and note down the Key ID.
Click Download to download the key file (you can only DOWNLOAD IT ONCE, DO NOT lose it) which is saved as a text file with a .p8 file extension.
3. Create a description file
Create and download a description file. Then, install the downloaded description file in the development or packaging environment.
4. Get the Team ID
- Log in to the Apple Developer Platform.
- In the sidebar, click Membership to view the Team ID.
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Add Apple as an authentication method for your project on Player Network Console.
For more details about integrating the SDK for other third-party channels, see JavaScript SDK.
Step 1: Install the JavaScript SDK
Install the SDK package from the production environment when launching the game. The SDK package from the test environment is only used for integration testing.
Install the JavaScript SDK from npm
or CDN
.
- npm
- CDN
$ npm install @intlsdk/account-api
// SDK production version package
<script src="https://common-web.intlgame.com/sdk-cdn/account-api/latest/index.umd.js"></script>
Step 2: Instantiate the SDK
Set env
to the test environment during the integration testing and env
to the corresponding production environment when launching the game.
const accountApi = new IntlgameAccountApi({
env: "test", // SDK environment
gameID: 11,
});
Parameter | Type | Description | Remark |
---|---|---|---|
env | string | SDK environment For more information, see Retrieve cluster information. | Required |
gameID | number | Unique game ID assigned by Player Network | Required |
Step 3: Implement web login
After instantiating the accountApi
component, call the thirdAuthorize
method to request the access token from Discord.
accountApi.ThirdAuthorize({
third_type: 'apple',
extra: {
appleAppId: 'xxxxx', // Required for apple login
}
}).then(
(res) => {
console.log(res);
});
With the Discord token returned, call the intlAuthorize
method to get the Player Network SDK OpenID and token to log in to your website.
accountApi.intlAuthorize({
third_type: 'apple',
channel_info: {
code: "EAAI2lTrXAZBwBAC"
user_name: "EAAI2lTrXAZBwBAC"
}
}).then(
(res) => {
console.log(res);
});
Call the intlLogout
method to log out from your website.
accountApi.intlLogout({
token: '4567xsdfsd',
openid: 'xxxxxxxx',
channel_id: 11,
}).then(
(res) => {
console.log(res);
});