public async Task StartAuthenticationProcess(Action <string> onAuthUrlAvailable, Action onError) { var validationToken = GenerateValidationToken(); var authUrl = GetAccessTokenRequestUrl(validationToken); TwitchOAuthResult accessToken = null; TaskCompletionSource <TwitchOAuthResult> tokenResult = new TaskCompletionSource <TwitchOAuthResult>(); GetAccessToken(authUrl, (token, user, userId) => { accessToken = new TwitchOAuthResult(); accessToken.AccessToken = token; accessToken.User = user; accessToken.UserID = userId; tokenResult.SetResult(accessToken); }, onError); if (onAuthUrlAvailable != null) { onAuthUrlAvailable(authUrl); } await tokenResult.Task; AccessTokenReceived?.Invoke(this, accessToken); }
public IEnumerator StartAuthenticationProcess() { var validationToken = GenerateValidationToken(); var authUrl = GetAccessTokenRequestUrl(validationToken); TwitchOAuthResult accessToken = null; GetAccessToken((token, user, userId) => { accessToken = new TwitchOAuthResult(); accessToken.AccessToken = token; accessToken.User = user; accessToken.UserID = userId; }); Application.OpenURL(authUrl); yield return(new WaitUntil(() => accessToken != null)); AccessTokenReceived?.Invoke(this, accessToken); Debug.Log(accessToken); }
protected void OnAccessTokenReceived(TokenReceivedEventArgs e) { AccessTokenReceived?.Invoke(this, e); }