This document is about: FUSION 2
SWITCH TO

Epic EOS認証

アプリケーション設定

Epic / EOSは簡単に認証プロバイダーとして追加できます。Photon Applications' Dashboardから数秒で完了します。
アプリケーションページから「Manage(管理)」ページへ移動し、「Authentication(認証)」セクションまでスクロールしてください。

必須設定

  • clientid: Epic Account Servicesでユーザー認証に使用するClient ID(IDトークン認証に使用)。ヒント: 現在この値はEOS dashboard > Product Settings > Clients ( > Details > Client ID)で調べられます。
  • catalogitemids (任意): 所有する必要があるアイテムのリスト(エントリーはセミコロンで区切ること)。※注意:ダッシュボードではキーは削除できず、値は空にできません。

クライアントサイド

クライアントは以下を送信する必要があります。

  • token: IDトークン (以下の「ユーザーにID Tokenを取得」を参照してください)
  • ownershipToken (任意): ダッシュボードでcatalogItemIdsが設定されている場合、クライアントはownershipTokenを送信する必要があります。NSがアイテムが所有されていることを検証します。

IDトークンを取得する

クライアントはTDトークンの取得にEpic Account Service APIを使用する必要があります。これについては
Clients have to use the Epic Account Service API to fetch an ID Token, which is described in Epicの「Auth Interface - Retrieving an ID Token For User(ユーザーにIDトークンを取得)」ドキュメントで説明されています。

Epicのドキュメントからの抜粋:「ゲームクライアントは、ユーザーがログインした後に EOS_Auth_CopyIdToken SDK APIを呼び出すことで、ローカルユーザーのIDトークンを取得できます。 このとき、EOS_Auth_CopyIdTokenOptions構造体にユーザーの EOS_EpicAccountId を含めて渡します。」

出力されるEOS_Auth_IdToken構造体には、ユーザーのEOS_EpicAccountIdと、IDトークンのデータを表すJWTが含まれています。なお、IDトークンの構造体を使用し終わったら、EOS_Auth_IdToken_Releaseを呼び出して解放する必要があります。

一度取得すれば、ゲームクライアントはそのIDトークンを他のパーティに提供できます。ログイン済みのローカルユーザーにとって、IDトークンは常に利用可能な状態です。

サンプルコード

これはIDトークンの取得に使用できます。

C#

// Call this method after login.
private bool GetLocalIdToken(out IdToken? a_IdToken)
{
    var options = new CopyIdTokenOptions()
    {
        AccountId = LocalUserId
    };

    // NOTE: Make sure to use the EOSAuthInterface to get the IdToken instead of the EOSConnectInterface.
    var result = EOSManager.Instance.GetEOSAuthInterface().CopyIdToken(ref options, out a_IdToken);

    if (result != Result.Success)
    {
        Debug.LogError("Failed to copy the IdToken.");
        return false;
    }

    return true;
}

AuthValuesは以下のようにセットアップされます。

C#

var authValues = new AuthenticationValues();
authValues.AuthType = CustomAuthenticationType.Epic;

var idToken = /* token retrieved by GetLocalIdToken */;
authValues.AddAuthParameter("token", idToken.Value.JsonWebToken.ToString());

Client.AuthValues = authValues;

Ownership Verification Tokenをリクエストする

Epicのドキュメントで任意の Ownership Verification Tokenを取得する方法が説明されています。

Back to top