Skip to content
UCIK Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Set up Google Play login

Configure your Google project and authenticate players in test and release builds.

Use Google Play Games for achievements, leaderboards, and snapshots. Use Request Google ID Token for a Google identity token accepted by EOS Connect or your backend.

Set up Android

  1. Configure Play Games Services for your app in Play Console. Link an Android OAuth credential with the packaged app’s package name and signing-certificate SHA-1. Play App Signing builds use the app-signing certificate, which can differ from your upload key.
  2. Add your test accounts to Play Games Services testers while the service configuration is unpublished. See Google’s setup guide.
  3. Set Web Client ID in Project Settings → Betide → Crossplay if you need ID tokens. This is a Web application OAuth client ID, separate from the Android credential.
  4. Set Play Games App Id under Betide → Tools to the numeric games-services project ID. Repackage after changing it; the value is written into Android resources during packaging.

Test on an Android device with the matching signed build and test account.

Sign in to Play Games

Sign in to Play Games
Sign in to Play Games
Preparing your graph…

Loading the interactive viewer.

Check Play Games authentication
Check Play Games authentication
Preparing your graph…

Loading the interactive viewer.

Game module dependencies: PlayGamesServices, BetideCore, Engine.

#include "Engine/GameInstance.h"
#include "Nodes/SignIn/GPIK_SignIn_AsyncFunction.h"

DEFINE_LOG_CATEGORY_STATIC(LogGameGoogleLogin, Log, All);

void SignInPlayGames(UGameInstance &GameInstance, bool bPrompt = true)
{
    auto *Login = bPrompt ? UGPIK_SignIn_AsyncFunction::SignIn(&GameInstance)
                          : UGPIK_SignIn_AsyncFunction::IsAuthenticated(&GameInstance);
    if (!Login)
        return;
    const TWeakObjectPtr<UGameInstance> WeakGameInstance(&GameInstance);
    Login->OnSuccessCallback = [WeakGameInstance](const FGPIK_PlayerInfo &Player) {
        if (WeakGameInstance.IsValid())
            UE_LOG(LogGameGoogleLogin, Log, TEXT("Signed in: %s"), *Player.DisplayName);
    };
    Login->OnFailureCallback = [WeakGameInstance](const FGPIK_PlayerInfo &) {
        if (WeakGameInstance.IsValid())
            UE_LOG(LogGameGoogleLogin, Warning, TEXT("Play Games sign-in failed"));
    };
    Login->Activate();
}

Sign-in tries automatic authentication before showing UI. The authentication check does not prompt.

Get a Google ID token

Google identity token
Preparing your graph…

Loading the interactive viewer.

#include "Nodes/SignIn/GPIK_GoogleSignIn_AsyncFunction.h"

void RequestGoogleToken(
    UObject *WorldContext, const FString &WebClientId,
    TFunction<void(const FGPIK_GoogleSignInResult &, const FBetideError &)> Completion)
{
    auto *Login = UGPIK_GoogleSignIn::RequestGoogleIdToken(WorldContext, WebClientId);
    if (!Login)
        return;
    Login->CompletionCallback = MoveTemp(Completion);
    Login->Activate();
}

The completion receives IdToken. Use a weak UObject capture if it updates game objects.

Pass the ID token explicitly to external-auth login, or use Login With Crossplay to compose provider sign-in. Request Server Side Access returns an authorization code for exchange on your backend; it is not an ID token. Never log either credential.

Account changes and failed sign-in

Sign Out from Google and Revoke Google Access affect Google Sign-In authorization. In C++, use UGPIK_GoogleSignInLibrary::SignOutFromGoogle() or RevokeGoogleAccess() from the token header. These do not replace your game’s crossplay logout.

For configuration failures, compare the installed build’s package name and signing certificate with the linked credential, then check the tester account and published service configuration. Signing into Google Play on the device alone does not authorize an unpublished game.

Next: Google Play services.

Was this page helpful?