Beispiel #1
0
        public async Task <IActionResult> Authentication(string code, string scope, string state)
        {
            var cleanedUrl  = Request.GetEncodedUrl().Replace(Request.QueryString.Value, "");
            var apiResponse = await TwitchValidationClient.GetAccessToken(code, cleanedUrl);

            if (apiResponse != null)
            {
                tokenDetails.Token        = apiResponse.Access_Token;
                tokenDetails.RefreshToken = apiResponse.Refresh_Token;

                tokenDetails.DateTimestamp = DateTime.UtcNow;

                JsonFileProcessor.SaveAccessTokenFile(tokenDetails);

                return(RedirectToAction("Index", "TwitchData"));
            }

            ViewData["AuthenticationUrl"] = TwitchValidationClient.GetAuthenticationUrl(Url.Action("Authentication", "TwitchData", null, Request.Scheme));
            return(View());
        }