Programming Quick Start
In this quick start guide, you will learn:
- How to make a basic configuration of
PgosSDKin programming. - The general process of programming with PGOS.
- How to integrate
FakeAccountandPlayerAuthin game client programming.
1. Retrieve the Development Configurations
Before doing this, please make sure you have a developer account and a title in PGOS Web Portal.
After that, you can log in to the protal to retrieve the necessary configurations for your title:
1.1 Enter PGOS Portal Console

1.2 Retrieve the Title ID and Title Region ID

1.3 Retrieve the Secret Key
Click the Setting link on the top bar, switch to Secret Keys tab, retrieve the Secret Key for game client.

To reduce the risk of Server Secret Key exposure, developers do not need to configure Secret Key for game server (dedicated server, DS). PgosSDK accomplishes this by the following methods:
- For local DS: A local DS refers to a Dedicated Server running on a non-PGOS Hosting machine, for which developers need to configure the
local_placer_id(either via code or file configuration). Thislocal_placer_idis an encrypted string embedding thesecret_keyandtitle_region_id. ThePgosSDKdecrypts it to obtain these configurations. The Secret Key embedded in thelocal_placer_idis valid only in the Dev and Test title regions. - For online DS: An online DS refers to a Dedicated Server running on a PGOS Hosting machine, which is deployed via the Build.
PgosSDKwill automatically retrieve necessary configurations (including thesecret_keyandtitle_region_id) from the PGOS hosting machine where DS runs, so no additional configuration is required for developers.
2. Programming in Game Project
The following is the general process of programming with PGOS, and it is also the sequence of calling PGOS APIs:
For game client:
graph LR A(CreatePGOS) -->B[InitConfig] B --> C[LoginPGOS] C -.-> D[Call PGOS APIs in Game Client] D -.-> E(LogoutPGOS) E -.-> F(DestroyPGOS)For game server:
graph LR A(CreatePGOS) -->B[InitConfig] B -.-> C[Call PGOS APIs in Game Server] C -.-> D(DestroyPGOS)
The following uses game client code to provide a quick start to PGOS programming. Integration for game servers is similar to the game client; for detailed DS Hosting integration, please refer to this document.
2.1 Programming with C++ API
2.1.1 Create and Init PGOS
Add the following codes to the appropriate location of your game project:
#include "PgosSDKCpp.h"
void SomeClass::StartupPGOS()
{
// You must create PGOS service before using PGOS service.
IPgosSDKCpp::Get().CreatePGOS();
// Init PGOS Config
TMap<FString, FString> Config;
Config.Add("title_id", "Your Title ID");
Config.Add("secret_key", "Your Client Secret Key");
IPgosSDKCpp::Get().GetClientAPI()->InitConfig(Config);
}
Call CreatePGOS() function in the main thread before using any PGOS service.
Call DestroyPGOS() function in the main thread during process shutdown if possible.
For more detail about PgosSDK instance management, you can refer to Client PgosSDK Instance Mode
For more detail about PGOS config, you can refer to Configure the PgosSDK.
It is recommended not to hardcode the original secret key in the code as it increases the risk of secret key leakage. An alternative approach is to hardcode a secret key encryption string and decrypt it at runtime.
const char* EncryptedSecretKey = "the ciphertext of the original secret key";
auto SecretKey = DecryptString(EncryptedSecretKey);
Config.Add("secret_key", SecretKey);
2.1.2 Make a Fake Account Log in
Add the following codes to the appropriate location of your game project, only works in game client:
#include "PgosSDKCpp.h"
void SomeUObjectClass::LoginFakeAccount()
{
auto spFAS = IPgosSDKCpp::Get().GetClientFakeAccountAPI();
if (spFAS)
{
FString MyAccount = TEXT("SomeAccountString"); // It can be made to support getting from the input.
auto CallbackFunction = IPgosSDKCpp::CreateWeakCallback<FClientFasLoginInfo>
(this, [this](const FPgosResult& Ret, const FClientFasLoginInfo* LoginInfo) {
UE_LOG(LogTemp, Log, TEXT("On FAS login callback."));
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess) {
this->AccountOpenID = LoginInfo->open_id; // Store OpenID for later use.
this->AccountToken = LoginInfo->token; // Store AccountToken for later use.
}
});
spFAS->Login(MyAccount, CallbackFunction);
}
}
FPgosFakeAccountAPI::Login receives a callback parameter of type TFunction (supporting lambda), and a CreateWeakCallback helper function is used here to ensure the security of object data access.
2.1.3 Make PGOS Authentication
Add the following codes to the appropriate location of your game project, only works in game client:
#include "PgosSDKCpp.h"
// After successful account login
void SomeUObjectClass::LoginPGOS()
{
auto playerAuth = IPgosSDKCpp::Get().GetClientPlayerAuthAPI();
if (playerAuth)
{
FClientLoginPGOSParams Params;
Params.account_provider = EAccountProvider::FAS;
Params.account_open_id = this->AccountOpenID;
Params.account_token = this->AccountToken;
Params.title_region_id = TEXT("region_id_to_login"); // Obtained from PGOS portal console.
auto CallbackFunction = IPgosSDKCpp::CreateWeakCallback<FClientAuthenticationInfo>
(this, [](const FPgosResult& Ret, const FClientAuthenticationInfo* LoginInfo) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess) {
UE_LOG(LogTemp, Log, TEXT("OnLoginPGOSSuccess: player_id=%s"), *LoginInfo->player_id);
}
else {
UE_LOG(LogTemp, Log, TEXT("OnLoginPGOSFailed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
playerAuth->LoginPGOS(Params, CallbackFunction);
}
}
For more detail about PGOS PlayerAuth, you can refer to PlayerAuth.
Now that the programming work is complete, build and run your game:
- If everything is working fine, you can see the successful log.
- If something is wrong, check the msg to see what happened.
For more detail about Calling PGOS C++ API, you can refer to Call PgosSDK C++ API.
2.2 Programming with Blueprint API
Programming with blueprint API is quite simple, you can search the following actions in the Executable Actions dialog:
PGOS | CreatePGOSPGOS | Client | InitConfigPGOS | Client | FakeAccount | AutoLoginPGOS | Client | PlayerAuth | LoginPGOS
Refer to the example below to drag and drop nodes on the appropriate blueprint:
Do remember to call
CreatePGOSin the blueprint if you want to use PGOS API in the blueprint, even if you have already called it in the C++ code.

When your programming work is complete, compile the blueprint and run your game:
- If everything is working fine, you can see the successful print log.
- If something is wrong, check the msg to see what happened.
For more detail about PgosSDK instance management, you can refer to Client PgosSDK Instance Mode
For more detail about PGOS config, you can refer to Configure the PgosSDK.
For more detail about PGOS FAS, you can refer to Using FAS.
For more detail about PGOS PlayerAuth, you can refer to PlayerAuth.
For more detail about Calling PGOS Blueprint API, you can refer to Call PgosSDK Blueprint API.