Exemple #1
0
        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);
        }
        private void ReceivedAccessToken(AccessTokenReceived e)
        {
            if (e.State == TwitchAuthViewModel.State &&
                e.TokenType == "bearer")
            {
                _accessToken = $"oauth:{e.AccessToken}";

                UpdatedFromTwitch = true;
            }
        }
        public async Task <IActionResult> Post(AccessTokenReceived accessTokenReceived)
        {
            bool result = await _mediator.Send(accessTokenReceived);

            if (result)
            {
                return(Ok());
            }

            return(Problem("Failed to save auth token."));
        }
        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);
 }
Exemple #6
0
        public IActionResult Post(AccessTokenReceived accessTokenReceived)
        {
            DomainEvents.Raise(accessTokenReceived);

            return(Ok());
        }