Authenticating With the SDK
The FACEIT SDK Authentication interface enables an external identity provider to integrate with and use the FACEIT ecosystem. The interface provides authentication services both for the FACEIT Server and Client SDKs.
Note that before authentication can be attempted, the SDK must first be initialised.
Client SDK Configuration
Authentication
The FACEIT Client SDK's Authentication interface provides access to FACEIT's game services for a game client. A player can associate one or more external user accounts, such as a Steam account they use for a particular game, with their FACEIT user account.
To use the SDK, the current player must be authenticated with FACEIT. This is performed by calling the FGCSDK_Auth_Login()
function on the Auth interface. No FACEIT Client SDK interfaces will operate before a successful authentication call through this interface.
Steam is commonly used as a third-party user authentication platform, as demonstrated in the example below. See the Steamworks documentation for more information on how to obtain an authentication token for a Steam user.
- C++
- UE4
- C#
#include "FACEITGameClientSDK/Auth/Auth.h"
FGCSDK_Auth_LoginCredentials credentials {};
// The auth platform is a supported authentication platform that the current
// player is logged into, eg. "steam".
credentials.authPlatform = "steam";
// The game ID is the ID of your game on FACEIT Game Studio or Labs Portal.
credentials.gameID = "...";
// The user auth token is a token obtained for the user for this auth platform,
// which proves their authenticity. For Steam, this token would be retrieved
// through Steamworks by making an ISteamUser::GetAuthSessionTicket() request.
// See https://partner.steamgames.com/doc/webapi_overview/auth for more information.
credentials.userAuthToken = "...";
// The result returned from this function call describes whether the login
// request was able to be initiated at all. If it was not, the result code
// represents the reason that the call failed, and the provided callback
// will not be called.
FGCSDK_Auth_ResultCode result = FGCSDK_Auth_Login(
&credentials,
[](const FGCSDK_Auth_LoginCallbackInfo* info)
{
// This function is called once the login request completes.
// info.authResult holds the result. If the returned result
// is successful, the user is logged into the FACEIT Client
// SDK, and the functionality of the SDK's interfaces is
// available for use.
},
nullptr
);
#include "FACEITUnrealClientPlugin/Auth/UFUCP_Auth.h"
void UMyGameInstance::PerformAuth()
{
UFUCP_Auth_LoginCredentials* Credentials = NewObject<UFUCP_Auth_LoginCredentials>(this);
// The auth platform is a supported authentication platform that the current
// player is logged into, eg. "steam".
Credentials.AuthPlatform = TEXT("steam");
// The game ID is the ID of your game on FACEIT Game Studio or Labs Portal.
Credentials.GameID = "...";
// The user auth token is a token obtained for the user for this auth platform,
// which proves their authenticity. For Steam, this token would be retrieved
// through Steamworks by making an ISteamUser::GetAuthSessionTicket() request.
// See https://partner.steamgames.com/doc/webapi_overview/auth for more information.
Credentials.UserAuthToken = "...";
// Function that will be called once the auth process completes - see below.
Credentials.LoginCallback.AddDynamic(this, &UMyGameInstance::OnFACEITAuthCompleted);
// The result returned from this function call describes whether the login
// request was able to be initiated at all. If it was not, the result code
// represents the reason that the call failed, and the provided callback
// will not be called.
EFUCP_Auth_ResultCode Result = UFUCP_Auth::Login(Credentials);
}
void UMyGameInstance::OnFACEITAuthCompleted(const FFUCP_Auth_LoginCallbackInfo& Info)
{
// This function is called once the login request completes.
// Info.AuthResult holds the result. If the returned result
// is successful, the user is logged into the FACEIT Client
// SDK, and the functionality of the SDK's interfaces is
// available for use.
}
using FACEITGameClientSDK;
Auth.ResultCode loginResult = Auth.Login(new Auth.LoginCredentials
{
// The auth platform is a supported authentication platform that the current
// player is logged into, eg. "steam".
AuthPlatform = "...",
// The game ID is the ID of your game on FACEIT Game Studio or Labs Portal.
GameID = "...",
// The user auth token is a token obtained for the user for this auth platform,
// which proves their authenticity. For Steam, this token would be retrieved
// through Steamworks by making an ISteamUser::GetAuthSessionTicket() request.
// See https://partner.steamgames.com/doc/webapi_overview/auth for more information.
UserAuthToken = "..."
},
(Auth.LoginCallbackInfo info) =>
{
// This function is called once the login request completes.
// info.AuthResult holds the result. If the returned result
// is successful, the user is logged into the FACEIT Client
// SDK, and the functionality of the SDK's interfaces is
// available for use.
});
User Upgrade
If the current user's authentication credentials are not recognised by the FACEIT backend, a guest account is created for the user. Guest accounts are anonymous and have limited functionality, but allow players to use the FACEIT platform without the friction of account sign-up.
The user may upgrade their guest account to a full FACEIT account, or may merge it into an exiting FACEIT account that they already own. To begin this process, calling the FGCSDK_Auth_GetAccountUpgradeURL()
function will return a URL that should be loaded into the user's web browser. When calling this function, the deepLink
parameter may be used to embed a redirection URL, which the upgrade process will invoke at the end of the flow to re-open the game. For example, steam://run/{YourGameId}
may be used to re-open a Steam game using the steam://
protocol.
Once the auth flow is complete and the game has been re-opened, the FGCSDK_Auth_CompleteAccountUpgrade()
function should be called to instruct the SDK to finalise the upgrade process. This will automatically re-authenticate the user and allow them access to the full suite of FACEIT account features within the game.
- C++
- UE4
- C#
#include "FACEITGameClientSDK/Auth/Auth.h"
#include "FACEITGameClientSDK/Utility/StringHelpers.h"
std::string MyGameClientInstance::GetUserUpgradeURL()
{
FGCSDK_Auth_GetAccountUpgradeURLData data {};
// This deep link can be whatever is most appropriate for your game.
data.deepLink = "steam://run/12345678";
// Fetch the URL.
return FGCSDK_ToString(&FGCSDK_Auth_GetAccountUpgradeURL, &data);
}
void MyGameClientInstance::CompleteUserUpgrade()
{
// Complete the account upgrade. The SDK must be polled
// regularly in order for this function to operate.
FGCSDK_Auth_ResultCode completionStarted = FGCSDK_Auth_CompleteAccountUpgrade(
[](const FGCSDK_Auth_CompleteUserUpgradeInfo* info)
{
std::cout << "Account upgrade " << (info->authResult == FGCSDK_AUTH_OK ? "succeeded" : "failed");
std::cout << "Is user upgraded: " << (info->userUpgraded ? "true" : "false");
},
nullptr);
}
#include "FACEITUnrealClientPlugin/Auth/UFUCP_Auth.h"
FString UMyGameClientInstance::GenerateUserUpgradeURL()
{
// Create the data object to pass to the plugin function.
UFUCP_Auth_GetAccountUpgradeURLData* data = NewObject<UFUCP_Auth_GetAccountUpgradeURLData>(this);
// This deep link can be whatever is most appropriate for your game.
data->DeepLink = "steam://run/12345678";
// Obtain the full URL from the plugin. The deep link specified above
// will be passed on via this full URL.
return UFUCP_Auth::GetAccountUpgradeURL(data);
}
void UMyGameClientInstance::PerformCompleteUserUpgrade()
{
// Create completion delegate and attach it.
// The callback will be called once the plugin has finalised the account upgrade.
CompleteUserUpgradeCallbackObject = NewObject<UFUCP_Auth_CompeteUserUpgradeCallback>(this);
CompleteUserUpgradeCallbackObject->CompleteUserUpgradeCallback.AddDynamic(
this,
&UMyGameClientInstance::OnFACEITUserUpgradeCompleted);
// Invoke the plugin function and let it do its thing.
// The plugin must be polled regularly in order for the
// finalisation to take place.
UFUCP_Auth::CompleteAccountUpgrade(CompleteUserUpgradeCallbackObject);
}
void UMyGameClientInstance::OnFACEITUserUpgradeCompleted(const FFUCP_Auth_CompleteUserUpgradeInfo& Info)
{
UE_LOG(
LogMyGame,
Log,
TEXT("OnFACEITUserUpgradeCompleted: Result: %s, User upgraded: %s"),
*UFUCP_Auth::GetResultCodeDescription(Info.AuthResult), Info.bUserUpgraded ? "True" : "False");
}
using FACEITGameClientSDK;
public partial class MyGameClientInstance
{
public string GetAccountUpgradeURL()
{
return Auth.GetAccountUpgradeURL(new Auth.GetAccountUpgradeURLData
{
DeepLink = "steam://run/12345678"
}
);
}
public void CompleteAccountUpgrade
{
Auth.ResultCode upgradeResult = Auth.CompleteAccountUpgrade(
(CompleteUserUpgradeInfo info) =>
{
Console.WriteLine(
"Result: " + Auth.GetResultCodeDescription(info.AuthResult) + " " +
"User upgraded: " + info.UserUpgraded);
}
);
}
}
Server SDK Configuration
Contrary to game clients, server applications are expected to be private, trusted applications that are under the control of the game developer. The server SDK's Auth interface must be provided with your game's API key before any other interfaces will function. This key can be found in your game's settings pages on the FACEIT Labs portal.
- C++
- UE4
- C#
#include "FACEITGameServerSDK/Auth/Auth.h"
FGSSDK_Auth_SetToken("my-game-auth-token");
#include "FACEITUnrealServerPlugin/Auth/UFUSP_Auth.h"
UFUSP_Auth::SetToken("my-game-auth-token");
using FACEITGameServerSDK;
Auth.SetToken("my-game-auth-token");