/// <summary> /// アカウントの認証<br /> /// <br /> /// create 関数で発行したユーザID・パスワードを使用してゲームプレイヤーの認証を行います。<br /> /// 認証が完了すると `アカウント認証情報` と `署名` が発行されます。<br /> /// `アカウント認証情報` と `署名` を GS2-Auth::Login にわたすことで、GS2の各サービスにアクセスするための `アクセストークン` を得ることができます。<br /> /// なおこのAPIとGS2-Auth::LoginをひとまとめにしたものがGS2-Profile::Loginではじめかた⇒サンプルプログラムで解説しています。<br /> /// <br /> /// `アカウント認証情報` と `署名` は1時間の有効期限が存在します。<br /> /// </summary> /// /// <returns>IEnumerator</returns> /// <param name="namespaceName">ネームスペース名</param> /// <param name="userId">アカウントID</param> /// <param name="keyId">認証トークンの暗号化に使用する暗号鍵 のGRN</param> /// <param name="password">パスワード</param> public IEnumerator Authentication( UnityAction <AsyncResult <EzAuthenticationResult> > callback, string namespaceName, string userId, string keyId, string password ) { yield return(_profile.Run( callback, null, cb => _client.Authentication( new AuthenticationRequest() .WithNamespaceName(namespaceName) .WithUserId(userId) .WithKeyId(keyId) .WithPassword(password), r => cb.Invoke( new AsyncResult <EzAuthenticationResult>( r.Result == null ? null : new EzAuthenticationResult(r.Result), r.Error ) ) ) )); }
public override IEnumerator Authentication(UnityAction <AsyncResult <AccessToken> > callback) { var accountClient = new Gs2AccountWebSocketClient(_session); string body = null; string signature = null; yield return(accountClient.Authentication( new AuthenticationRequest() .WithNamespaceName(_accountNamespaceName) .WithUserId(_userId) .WithPassword(_password) .WithKeyId(_keyId), r => { if (r.Error != null) { callback.Invoke( new AsyncResult <AccessToken>( null, r.Error ) ); } else { body = r.Result.body; signature = r.Result.signature; } } )); if (body == null || signature == null) { yield break; } var authClient = new Gs2AuthWebSocketClient(_session); yield return(authClient.LoginBySignature( new LoginBySignatureRequest() .WithUserId(_userId) .WithKeyId(_keyId) .WithBody(body) .WithSignature(signature), r => { if (r.Error != null) { callback.Invoke( new AsyncResult <AccessToken>( null, r.Error ) ); } else { callback.Invoke( new AsyncResult <AccessToken>( new AccessToken() .WithToken(r.Result.token) .WithExpire(r.Result.expire) .WithUserId(r.Result.userId), r.Error ) ); } } )); }