public Client(Gs2.Unity.Util.Profile profile) { _profile = profile; _client = new Gs2AccountWebSocketClient(profile.Gs2Session); if (profile.checkRevokeCertificate) { _restClient = new Gs2AccountRestClient(profile.Gs2RestSession); } else { _restClient = new Gs2AccountRestClient(profile.Gs2RestSession, new DisabledCertificateHandler()); } }
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 ) ); } } )); }