アイデンティティプロバイダーとしてGoogleを設定する
注釈:本資料はAI技術を用いて翻訳されています。
Overview
このガイドでは、開発者がGoogleアカウントをAccelByte Gaming Services(AGS)に接続する方法を説明します。ゲームによっては、ここに記載されていないGoogleサービス内の追加機能を設定する必要がある場合があります。Googleサービスの設定に関する詳細については、Googleの担当者に直接お問い合わせいただくか、Google Cloudドキュメントを直接参照することをお勧めします。
このガイドは一般公開を目的としており、機密性のため限られた情報のみを含んでいます。まず、完全な機密ガイドを参照することをお勧めします。機密ガイドのコピーをリクエストするには、AccelByteのテクニカルプロデューサーにお問い合わせください。
Goals
AGS SDKを使用するゲーム、およびパブリッシャーのWebサイト(AGS Player Portalを使用)で、Google認証方式を有効にします。
Prerequisites
For web login integration
- Google Cloud Consoleアカウント。
- 認証を設定し、権限を管理するためのAGS Admin Portalアカウント。
- Player Portalとランチャー用のパブリッシャーネームスペース。
- Player Portal。
ウェブログイン統合は現在AGS Public Cloudでは利用できず、AGS Private Cloudでのみサポートされています。
For in-game Android login integration
- Google Cloud Consoleアカウント。
- Google Play Consoleアカウント。
- Unreal Engineを使用している場合、以下が必要です。
- Unity Engineを使用している場合、以下が必要です。
- Unity Android Environment Setupに従ってください
- AGSのUnity SDKとUnity SDK Googleの最新バージョンを用意してください。
- AGS SDKの最新バージョンがインポートされたUnityまたはUnrealのゲームプロジェクト。
- 認証を設定し、権限を管理するためのAGS Admin Portalアカウント。
- AGSのゲームネームスペース。
- AGS Identity and Access Management(IAM)Clientsについての知識。
Set up Google Cloud and Google Play
For web login (Cloud and Play)
Create a Google Cloud Identity
Google Cloud Identity組織を作成します。Set up Cloud Identity as a Google Cloud admin guideに従ってください。
Create a Google Console project
Google Console上で新しいプロジェクトを作成します。Create a Google Cloud project Guideに従ってください。
Set up OAuth consent
OAuth consent screenで、アプリにopenidスコープを追加します。ユーザーの同意に関する詳細については、Configure the OAuth consent screen pageを参照してください。
Create OAuth credentials
WebアプリケーションタイプでOAuth認証情報を作成し、以下のURLをOAuth Authorized redirect URIsに追加します。
https://{BaseURL}https://{BaseURL}/iam/v3/platforms/google/authenticatehttps://{BaseURL}/player/account/linked-accountshttps://{BaseURL}/account/linked-accountshttps://{BaseURL}/account/linked-accounts?platformId=googlehttps://{BaseURL}/iam/v3/public/namespaces/{namespace}/users/me/platforms/google/web/link/establishhttp://127.0.0.1
BaseURLはご自身のドメインアドレスです。例:https://development.accelbyte.io。
詳細については、GoogleのSetting up OAuth 2.0ガイドに従ってください。
Create a Google Android app
Googleアプリを作成します。Create and set up your app guideに従ってください。
Create a project app
- Unreal Engine Instructions
- Unity Engine Instructions
指定したキーストアを使用して、空のUnrealプロジェクトをAAB形式でビルドします。Unrealプロジェクト用のキーストアの生成に関する詳細は、Signing Projects for Releaseガイドを参照してください。
指定したキーストアを使用して、空のUnityプロジェクトをAAB形式でビルドします。Unityプロジェクト用のキーストアの生成と使用に関する詳細は、UnityのAndroid Keystore記事を参照してください。
Create a release for your project
アプリのリリースを作成します。Prepare and roll out a release guideに従ってください。
Set up Google Play Games Services
Google Play Games Servicesを設定します。Setting Up Google Play Games Services guideに従ってください。以下を行う必要があります。
- Play Games Servicesプロジェクトを作成します。
- Google Cloud Platform上でOAuth consent screenを作成します。OAuth consent screenで、アプリに以下の4つのスコープを追加します。
- openid
- .../auth/games
- .../auth/games_lite
- .../auth/drive.appdata
- 認証情報を作成します。
すべての設定が完了したら、確認して公開します。
Set up a Google login method
For web login (Google)
Player PortalでGoogleログインを設定するには、以下の手順に従ってください。これにより、プレイヤーはウェブからGoogleアカウントを使用してサインインできるようになります。
-
パブリッシャーネームスペース配下でAGS Admin Portalにログインします。Foundations > 3rd Party Integrations > Auth & Account Linkingに移動し、+ Add Newをクリックします。
-
Googleをクリックし、Google Cloud Consoleの認証情報でログイン設定を入力します。完了したらCreateをクリックします。
- Client ID: Google OAuthのClient IDを入力します。
- Client Secret: Google OAuthのClient Secretを入力します。
- Redirect URI: Google OAuthのAuthorized Redirect URIを入力します:
https://<BaseURL>/iam/v3/platforms/google/authenticate。
注記<BaseURL>はご自身のドメインアドレスに置き換えてください。例:https://development.accelbyte.io -
詳細ページでActivateをクリックし、確認のポップアップで再度Activateをクリックします。
Test Google web login
-
AGS Player Portal(例:
https://development.accelbyte.io)にアクセスし、Loginをクリックします。 -
Sign up or log in withの下で、Googleアイコンを見つけてクリックします。表示されていない場合はMore login optionsをクリックしてください。
-
Googleの認証情報を使用してログインします。
Activate Google login for a specific domain and role
Googleログイン統合により、特定のGoogleドメインを使用したログインを処理し、特定のロールを直接割り当てることができます。例えば、組織のメンバーがGoogle組織アカウントを使用してAGS Admin Portalにログインできるようにしたい場合、Google組織ドメインを登録できます。
これはパブリッシャーネームスペースでのみ行うことができます。
-
Google Login Configurationで、+ Register Domainボタンをクリックします。Domain Name、Clientsを入力します。

- Domain Nameは、ご自身のGoogle組織アカウントのドメインです。形式の例:
yourdomain.io。 - Clientsは、Admin PortalのIAM Client Nameです。IAM Clientの詳細については、Manage access control for applications guideを参照してください。
- Default Roleは、Google組織アカウントを使用してAdmin Portalにログインした際に、組織のメンバーに割り当てられるロールです。値の例:
Admin Portal。ロールの詳細については、Manage access control for user accounts guideを参照してください。
Use a Google Organization Account for the Admin Portal
上記の手順の後、Google組織アカウントを使用してAdmin Portalにログインするには、以下の手順を使用してください。
-
Admin Portalにアクセスし、GoogleアイコンをクリックしてGoogleでログインします。

-
Google組織アカウントの認証情報でログインします。これにより、管理者としてログインします。

For in-game login
ゲーム用にGoogleログインを設定するには、以下の手順に従ってください。これにより、プレイヤーはGoogleアカウントを使用してゲームにサインインできるようになります。
-
パブリッシャーネームスペース配下でAGS Admin Portalにログインします。Foundations > 3rd Party Integrations > Auth & Account Linkingに移動し、+ Add Newをクリックします。
-
Googleをクリックし、Google Cloud Consoleの認証情報でログイン設定を入力します。完了したらCreateをクリックします。
- Client ID: Google OAuthのClient IDを入力します。
- Client Secret: Google OAuthのClient Secretを入力します。
- Redirect URI: localhostのURIを入力します:
http://127.0.0.1
-
詳細ページでActivateをクリックし、確認のポップアップで再度Activateをクリックします。
Create an IAM client
IAM Clientは、対象プラットフォームでリリースしたいゲームクライアントを表すものです。IAM Clientの詳細については、Manage access control for applicationsを参照してください。
In-game login instructions
このドキュメントに従うことで、AGS SDKを使用してゲームのサインインプロセスを統合し、プレイヤーがGoogleアカウントを使用してゲームにログインできるようにできます。プレイヤーがGoogleの認証情報でゲームまたはプラットフォームにログインするためには、ゲームがプレイヤーが使用している認証情報を持つGoogleプラットフォームからのAuthトークンをパブリッシャープラットフォームに渡す必要があります。
各ゲームエンジンでの設定は異なります。利用可能なタブからお使いのゲームエンジンを選択してください。
- Unreal Engine Instructions
- Unity Engine Instructions
In-game login integration (Unreal)
Preparation and configuration (Unreal)
Preparing source code (Unreal)
Googleオンラインサブシステムを使用できるようにするには、専用のUnreal Engineソースコードが必要です。
- Epic GamesのGitHubからUnreal Engineバージョン4.27.2をダウンロードします:Release Unreal Engine 4.27.2 · EpicGames/UnrealEngine (github.com)。
- ソースコードの一部を修正する必要があります。
-
Server Auth Codeを有効にします。
- Unreal Engineインストールディレクトリに移動し、
Engine\Plugins\Online\OnlineSubsystemGoogle\Source\ThirdParty\Android\Java\フォルダにあるGoogleLogin.javaファイルを開きます。このファイルに以下の変更を加えます。
-
public boolean init(String inClientId, String inServerClientId)に移動し、下にスクロールして.requestServerAuthCode(serverClientId)の部分のコメントを解除します。// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(serverClientId)
.requestProfile()
.requestServerAuthCode(serverClientId)
.requestEmail()
.build();
// Build a GoogleSignInClient with the options specified by gso.
mGoogleSignInClient = GoogleSignIn.getClient(activity, gso); -
private String getAuthTokenJsonStr(GoogleSignInAccount acct)に移動し、下にスクロールしてaccess_tokenの値をandroidInternalからacct.getServerAuthCode()に変更します。private String getAuthTokenJsonStr(GoogleSignInAccount acct)
{
if (acct != null)
{
return "{\"access_token\":\""+ acct.getServerAuthCode() + "\"," + //androidInternal\"," +
"\"refresh_token\":\"androidInternal\"," +
"\"id_token\":\""+ acct.getIdToken() + "\"}";
}
return "";
}
- Unreal Engineインストールディレクトリに移動し、
-
RESTful実装を無効にします。
- Unreal Engineインストールディレクトリに移動し、
Engine\Plugins\Online\OnlineSubsystemGoogle\Source\フォルダにあるOnlineSubsystemGoogle.Build.csファイルを開きます。以下の変更を加えます。
-
constructorに移動し、bool bUsesRestfulImpl = false;を追加します。public class OnlineSubsystemGoogle : ModuleRules
{
public OnlineSubsystemGoogle(ReadOnlyTargetRules Target) : base(Target)
{
bool bUsesRestfulImpl = false;
PrivateDefinitions.Add("ONLINESUBSYSTEMGOOGLE_PACKAGE=1");
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PrivateIncludePaths.Add("Private"); -
すべての変更後、C++コードを再コンパイルして、変更内容がAndroidビルドのパッケージ化に含まれるようにします。
-
同じディレクトリで
OnlineSubsystemGoogle.pluginファイルを開きます。 -
そのファイルの
Modulesの下で、WhitelistPlatformsに値Androidを追加します。{
"FileVersion" : 3,
"FriendlyName" : "Online Subsystem Google",
"Version" : 1,
"VersionName" : "1.0",
"Description" : "Access to Google platform",
"Category" : "Online Platform",
"CreatedBy" : "Epic Games, Inc.",
"CreatedByURL" : "http://epicgames.com",
"EnabledByDefault" : false,
"Modules": [
{
"Name": "OnlineSubsystemGoogle",
"Type": "Runtime",
"LoadingPhase" : "Default",
"WhitelistPlatforms" :
[
"Win64","Win32", "Android"
]
}
],
"Plugins": [
{
"Name": "OnlineSubsystem",
"Enabled": true
}
]
}
- Unreal Engineインストールディレクトリに移動し、
-
Creating a project (Unreal)
新しいUnreal Engineプロジェクトを作成した後、いくつかの項目を設定・構成する必要があります。
Enable OnlineSubsystemGoogle plugins and service configurations (Unreal)
-
プロジェクトファイルでプラグインを有効にします。
{
"FileVersion": 3,
"EngineAssociation": "{4D293DA0-4F8F-387E-BF30-77B1100DBEBF}",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "TestGoogleLogin",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
],
"Plugins": [
{
"Name": "AccelByteUe4Sdk",
"Enabled": true
},
{
"Name": "OnlineSubsystemGoogle",
"Enabled": true
}
]
} -
<project>/Config/Androidディレクトリで、AndroidEngine.iniファイルを開き、以下の変更を加えます。[OnlineSubsystem]
; For Android, our native service will be Google Play
DefaultPlatformService=GooglePlay
NativePlatformService=Google
[OnlineSubsystemGoogle]
bEnabled=True
ClientId=662680510101-gojaaltsfsg4ei75afnfii3e43ebocgp.apps.googleusercontent.com
ServerClientId=662680510101-gojaaltsfsg4ei75afnfii3e43ebocgp.apps.googleusercontent.com
ClientSecret=GOCSPX-zR_pvAu6EruK-s0yf2v3********
[OnlineSubsystemGoogle.OnlineIdentityGoogle]
+ScopeFields="email"
+ScopeFields="profile"
+ScopeFields="https://www.googleapis.com/auth/userinfo.email"
+ScopeFields="https://www.googleapis.com/auth/userinfo.profile"
[OnlineSubsystemGooglePlay]
bEnabled=True
[OnlineSubsystemGooglePlay.Store]
bSupportsInAppPurchasing=True
bUseStoreV2=False
[/Script/AccelByteUe4Sdk.AccelByteSettings]
ClientId=a342f59f3489476ca02d704c75891a3b
ClientSecret=k@#h,G]R^C61#2d!************
Namespace=sdktest
PublisherNamespace=accelbyte
BaseUrl="https://development.accelbyte.io"注記OnlineSubsystemGoogle ClientIdはGoogle Play Console上のゲームサーバー認証情報から取得され、**AccelByteClientId**はIAM Clientの認証情報から取得されます。 -
プロジェクトのプラグインとモジュール
-
[PROJECT].Build.cs// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class TestGoogleLogin : ModuleRules
{
public TestGoogleLogin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore",
"OnlineSubsystem",
"OnlineSubsystemUtils",
"Sockets", "Networking", "InputCore", "AccelByteUe4Sdk", "Json", "JsonUtilities", "Http", "WebSockets"
});
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your project file with the Enabled attribute set to true
}
} -
[PROJECT].Target.csファイルと[PROJECT]Editor.Target.csファイル// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class TestGoogleLoginEditorTarget : TargetRules
{
public TestGoogleLoginEditorTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "TestGoogleLogin", "OnlineSubsystem", "AccelByteUe4Sdk" } );
ProjectDefinitions.Add("ONLINE_SUBSYSTEM_EOS_ENABLE_GOOGLE=1");
}
}// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class TestGoogleLoginTarget : TargetRules
{
public TestGoogleLoginTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "TestGoogleLogin", "OnlineSubsystem", "AccelByteUe4Sdk" } );
ProjectDefinitions.Add("ONLINE_SUBSYSTEM_EOS_ENABLE_GOOGLE=1");
}
}
-
Project settings (Unreal)
Unrealプロジェクトのパッケージング、Androidプラットフォーム、Credential/Licenseを設定します。
Generating keystore (Unreal)
- Signing projects for release guideに従ってください。
C:\Program Files\Android\Android Studio\jre\binディレクトリに移動し、keystore.exeを開きます。- コマンドを実行します:
keytool -genkey -v -keystore ExampleKey.keystore -**alias** MyKey -keyalg RSA -keysize 2048 -validity 10000。 - 生成された
*.keystoreファイルをjustice-unreal-sdk-project - Android\Build\Androidの場所に配置します。
Sample code implementation (Unreal)
- クラスアクターを作成し、そのレベルにGoogleネイティブログインとAGSのAccessサービスを配置できます。以下は例です。
SampleActor.h
// Fill out your copyright notice in the Description page of Project Settings.
##pragma once
##include "CoreMinimal.h"
##include "GameFramework/Actor.h"
##include "Kismet/GameplayStatics.h"
##include "OnlineSubsystem.h"
##include "Interfaces/OnlineIdentityInterface.h"
##include "Interfaces/OnlinePurchaseInterface.h"
##include "Core/AccelByteRegistry.h"
##include "Api/AccelByteUserApi.h"
##include "SampleActor.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FActionInfo, FString, Message);
UCLASS()
class TESTGOOGLELOGIN_API ASampleActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASampleActor();
UPROPERTY(BlueprintAssignable)
FActionInfo OnActionInfoUpdated;
UFUNCTION(BlueprintCallable)
void ExecBroadcast();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
FApiClientPtr ApiClient = nullptr;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
スニペットで使用されているAccelByteOnlineSubsystemPtrを取得するには、このガイドに従ってください。
SampleActor.cpp
// Fill out your copyright notice in the Description page of Project Settings.
##include "SampleActor.h"
// Sets default values
ASampleActor::ASampleActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient(TEXT("YOUR_KEY"));
}
// Called when the game starts or when spawned
void ASampleActor::BeginPlay()
{
Super::BeginPlay();
}
void ASampleActor::ExecBroadcast()
{
OnActionInfoUpdated.Broadcast(TEXT("Begin Sample Actor"));
const IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::GetByPlatform();
if (OnlineSubsystem == nullptr)
{
FString Message = TEXT("Cannot login with no online subsystem set!");
OnActionInfoUpdated.Broadcast(Message);
return;
}
const IOnlineIdentityPtr OnlineIdentity = OnlineSubsystem->GetIdentityInterface();
if (!OnlineIdentity.IsValid())
{
FString Message = TEXT("Could not retrieve identity interface from native subsystem.");
OnActionInfoUpdated.Broadcast(Message);
return;
}
APlayerController* MyPlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);; // = PlayerControllerWeakPtr.Get();
const ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(MyPlayerController->Player);
if (LocalPlayer == nullptr)
{
FString Message = TEXT("Can only login with native platform for local players");
OnActionInfoUpdated.Broadcast(Message);
return;
}
const FVoidHandler OnLoginSuccessDelegate = FVoidHandler::CreateLambda([=]() {
OnActionInfoUpdated.Broadcast(TEXT("Login to AB Service Success"));
});
const FErrorHandler OnLoginErrorDelegate = FErrorHandler::CreateLambda([=](int32 ErrorCode, const FString& ErrorMessage) {
FString Message = FString::Printf(TEXT("Error Login to AB Service : %s"), *ErrorMessage);
OnActionInfoUpdated.Broadcast(Message);
});
const FOnLoginCompleteDelegate NativeLoginComplete = FOnLoginCompleteDelegate::CreateLambda([=]
(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error) {
FString Message = FString::Printf(TEXT("OnLoginComplete %s : %s"), bWasSuccessful ? TEXT("Success") : TEXT("Fail"), *Error);
OnActionInfoUpdated.Broadcast(Message);
if (bWasSuccessful)
{
const FString PlatformToken = OnlineIdentity->GetAuthToken(LocalPlayer->GetControllerId());
UE_LOG(LogTemp, Warning, TEXT("PlatformToken : %s"), *PlatformToken);
OnActionInfoUpdated.Broadcast(FString::Printf(TEXT("PlatformToken : %s"), *PlatformToken));
auto UserApi = ApiClient->GetUserApi().Pin();
UserApi->LoginWithOtherPlatform(EAccelBytePlatformType::Google, PlatformToken, OnLoginSuccessDelegate, OnLoginErrorDelegate);
UE_LOG(LogTemp, Warning, TEXT("Request LoginWithOtherPlatform"));
OnActionInfoUpdated.Broadcast(TEXT("Request LoginWithOtherPlatform"));
}
});
OnlineIdentity->AddOnLoginCompleteDelegate_Handle(LocalPlayer->GetControllerId(), NativeLoginComplete);
const bool bWaitForDelegate = OnlineIdentity->Login(LocalPlayer->GetControllerId(), FOnlineAccountCredentials());
if (!bWaitForDelegate)
{
FString Message = TEXT("The online subsystem couldn't login");
OnActionInfoUpdated.Broadcast(Message);
}
FString Message = TEXT("Sending login request to native subsystem!");
OnActionInfoUpdated.Broadcast(Message);
}
// Called every frame
void ASampleActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
Google認証におけるplatform_tokenはAuthトークンです。
- その後、ウィジェットブループリントと合わせて実装・統合します。
Sample code testing (Unreal)
すべての設定、構成、および一部の実装が完了したら、アプリをコンパイルしてAndroidデバイスにデプロイします。その後、GoogleネイティブログインサービスからAGSにログインできます。
- お使いのPCでAndroidデバイスが検出されていることを確認し、ターミナルで以下のコマンドを実行します:
adb devices - プロジェクトをAndroid(ASTC)にパッケージ化します。
- Androidデバイスにアプリをインストールして実行します。
Upload the project to Google Play Console (Unreal)
指定したキーストアを使用して、UnrealプロジェクトをAAB形式でビルドします。まだUnrealプロジェクトへのGoogleログインの設定が完了していない場合は、空のプロジェクトでも構いません。ゲームを公開した後、テストの準備が整います。
まだゲームを公開していない場合、Googleアカウントでゲームをテストできるようにするため、テスターアカウントを追加する必要があります。Set up an open, closed, or internal test guideに従ってください。
In-game login integration (Unity)
AccelByte Unity SDK Google拡張機能を使用すると、Googleアカウントの機能をAGSと統合できます。この拡張機能はGitHubで見つけてダウンロードできます。拡張機能をインストールし、ゲームにGoogleログインを実装するには、GitHub上の拡張機能のインストールガイドに従ってください。
Upload project to Google Play Console (Unity)
指定したキーストアを使用して、UnityプロジェクトをAAB形式でビルドします。Delivering to Google Play guideに従ってください。まだUnityプロジェクトへのGoogleログインの設定が完了していない場合は、空のプロジェクトでも構いません。ゲームを公開した後、テストの準備が整います。
まだゲームを公開していない場合、Googleアカウントでゲームをテストできるようにするため、テスターアカウントを追加する必要があります。これを行うには、Set up an open, closed, or internal test guideに従ってください。