public async Task <IActionResult> Index(OAuthTesterViewModel oAuthTesterViewModel) { var state = StateUtils.Generate(); var oAuthClientConfiguration = oAuthTesterViewModel.OAuthClientConfiguration; var oAuthFlows = _oAuthFlowsFactory.CreateOAuthFlows(oAuthClientConfiguration.Name); var response = await oAuthFlows.RunFlow(oAuthClientConfiguration, state, oAuthTesterViewModel.Username, oAuthTesterViewModel.Password, ResponseModes.FormPost); switch (response) { case OAuthRedirect oAuthRedirect: TempData[Common.State] = oAuthRedirect.State; TempData[Common.CodeVerifier] = oAuthRedirect.CodeVerifier; TempData[TempDataNames.OAuthTesterConfigurationName] = oAuthTesterViewModel.ConfigurationName; return(Redirect(oAuthRedirect.Uri)); case AccessTokenResponse accessTokenResponse: oAuthTesterViewModel.AccessTokenResponse = Utils.Mappers.OAuthMapper.Map(accessTokenResponse); break; case DeviceCodeResponse deviceCodeResponse: TempData[TempDataNames.OAuthTesterConfigurationName] = oAuthTesterViewModel.ConfigurationName; TempData.Write(TempDataNames.DeviceCodeResponse, deviceCodeResponse); return(RedirectToAction(nameof(PingDeviceToken))); case ErrorResponse errorResponse: return(ProcessOAuthClientErrorResponse(errorResponse)); } return(View(oAuthTesterViewModel)); }
public static OAuthTesterViewModel GetNewOAuthTesterViewModel(string configurationName = null) { var destionation = new OAuthTesterViewModel { ConfigurationName = configurationName ?? OAuthConfigurationNames.ClientCredentials, AvailableConfigurationNames = GetAvailableConfigurationNames() }; return(destionation); }