private IEnumerator SendAuthorizationRequest(string accessToken, int gameVersion, string[] selectedGroups = null) { if (!_rDataClient.IsAvailable) { // If we made it this far, there is probably no reason for data collection not to authorize us when the connection is available again. // Pretend that we will be to start collecting data that will be sent once we reconnect to the server Authorized = true; LastError = new RDataServerNotAvailableException("Data collection server is not available"); yield break; } var request = new RData.Authentication.JsonRpcRequests.JwtAuthorizationRequest(accessToken, gameVersion, selectedGroups); yield return(CoroutineManager.StartCoroutine(_rDataClient.Send <RData.Authentication.JsonRpcRequests.JwtAuthorizationRequest, BooleanResponse>(request))); if (request.Response.HasError) { LastError = new RDataAuthorizationException(request.Response.Error); yield break; } else { Authorized = request.Response.Result; } }
public IEnumerator Authorize() { if (_rDataClient.Authorized) { LastError = new RDataAuthorizationException("Already authorized"); yield break; } if (!_jwtAuthClient.Authenticated) { LastError = new RDataAuthorizationException(string.Format("You must call {0}.Authenticate before calling {1}.Authorize", typeof(JwtAuthenticationClient).Name, typeof(JwtAuthorizationStrategy).Name)); yield break; } yield return(CoroutineManager.StartCoroutine(SendAuthorizationRequest(_jwtAuthClient.AccessToken, _rDataClient.GameVersion, _jwtAuthClient.SelectedGroups))); if (_rDataClient.Authorized) { _rDataClient.OnAuthorized(); } }