Web
This article guides you through setting up Epic as an identity provider, enabling your website to access Player Network authentication services.
Prerequisites
- Set up your app on the Epic Developer Portal.
- Add developers to your organization as members with the appropriate role permissions.
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Add Epic 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 Epic.
accountApi.thirdAuthorize({
third_type: 'epic',
}).then(
(res) => {
console.log(res);
});
With the Epic 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: 'epic',
channel_info: {
openid: "EAAI2lTrXAZBwBAC" //the response parameter account_id returned from the thirdAuthorize interface
nickname: "EAAI2lTrXAZBwBAC"
access_token: "EAAI2lTrXAZBwBAC"
refresh_token: "EAAI2lTrXAZBwBAC"
expires_in: "EAAI2lTrXAZBwBAC"
refresh_expires_in: "EAAI2lTrXAZBwBAC"
}
}).then(
(res) => {
console.log(res);
});
Call the intlLogout
method to log out from your website.
accountApi.intlLogout({
token: '4567xsdfsd',
openid: 'xxxxxxxx',
channel_id: 24,
}).then(
(res) => {
console.log(res);
});