logging_in - YoYoGames/GMEXT-EpicOnlineServices GitHub Wiki
Epic Online Services offers several ways to log in and authenticate. When you use the Epic Online Services extension in your GameMaker game you should aim to use the Preferred Login Types for Epic Account:
Platform | Login Type | Summary |
---|---|---|
Epic Games Launcher | EOS_LOGIN_CREDENTIAL_TYPE.EXCHANGE_CODE |
Exchange code received from the launcher and used to automatically login the user. |
Steam Client | EOS_LOGIN_CREDENTIAL_TYPE.EXTERNAL_AUTH |
Steam Session Ticket used to automatically login the Steam user to their associated Epic account. |
Other store platforms and standalone distributions on PC and Mobile Devices |
EOS_LOGIN_CREDENTIAL_TYPE.ACCOUNT_PORTAL with EOS_LOGIN_CREDENTIAL_TYPE.PERSISTENT_AUTH
|
Users are prompted to login using their Epic account credentials, after which a long-lived refresh token is stored locally to enable automatic login across consecutive application runs. |
Note
See (EOS_LOGIN_CREDENTIAL_TYPE) for the Login Type constants of the extension.
When you log into Epic Online Services using the extension, a straightforward way is to use the Epic Games Launcher. The launcher opens the game by running the executable, along with a few command-line parameters:
-AUTH_LOGIN=unused -AUTH_PASSWORD=<password> -AUTH_TYPE=exchangecode -epicapp=<appid> -epicenv=Prod -EpicPortal -epicusername=<username> -epicuserid=<userid> -epiclocale=en-US -epicsandboxid=<sandboxid> -epicdeploymentid=<deploymentid>
The AUTH_PASSWORD
parameter value contains the token that you should pass into eos_auth_login. This function should then be called with a credential type of EOS_LOGIN_CREDENTIAL_TYPE.EXCHANGE_CODE
. The id
parameter can be blank (an empty string ""
), as this login method does not require an ID. The token
parameter needs to be set to the Exchange Code from the AUTH_PASSWORD
command line parameter.
// Retrieve the AUTH_PASSWORD command-line parameter
// (available when launching from the Epic Games Launcher)
var _p_num = parameter_count();
var _p_auth_password = "";
if (_p_num > 0)
{
for (var i = 0; i < _p_num; i++)
{
var _param = parameter_string(i + 1);
if(string_pos("AUTH_PASSWORD", _param))
{
_p_auth_password = string_copy(_param, 16, string_length(_param));
}
}
}
// Login using the AUTH_PASSWORD as the token parameter
eos_auth_login(
EOS_LOGIN_CREDENTIAL_TYPE.EXCHANGE_CODE,
EOS_AUTH_SCOPE_FLAGS.BASIC_PROFILE | EOS_AUTH_SCOPE_FLAGS.FRIENDS_LIST | EOS_AUTH_SCOPE_FLAGS.PRESENCE,
"",
_p_auth_password,
-1
);
Note
The permissions that you pass must correspond exactly to the ones you set in the Developer Portal. See Permissions.
This is a detailed login flow for external accounts (the required credentials depend on the EOS_EXTERNAL_CREDENTIAL_TYPE used with the eos_auth_login API).
- Game calls eos_auth_login with the
EOS_LOGIN_CREDENTIAL_TYPE.EXTERNAL_AUTH
credential type. -
eos_auth_login callback returns a status
EOS_RESULT.INVALID_USER
with a non-undefined EOS_ContinuanceToken in the EOS_Auth_LoginCallbackInfo data. - Game calls eos_auth_link_account with the
EOS_ContinuanceToken
to initiate the login flow for linking the platform account with the user's Epic account. - EOS SDK automatically opens the local default web browser and takes the user to the Epic account portal web page.
- The user is able to login to their existing Epic account or create a new account if needed.
- In the meantime, EOS SDK will internally keep polling the backend for a completion status of the login flow.
- The user is able to login to their existing Epic account or create a new account if needed.
- In the meantime, EOS SDK will internally keep polling the backend for a completion status of the login flow.
- Once user completes the login, cancels it or if the login flow times out, eos_auth_link_account invokes the completion callback to the caller.
- If the user was logged in successfully,
EOS_RESULT.SUCCESS
is returned in the callback event. Otherwise, an error result code is returned accordingly.