public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) { HttpRequestMessage request = context.Request; var authenticated = await _oAuthService.CheckAuthenticationAsync(); if (authenticated == false) { context.ErrorResult = new AuthenticationFailureResult(new { Error = 401, Message = "Unauthorized" }, request); } }
public async Task <ActionResult> Index() { var authenticated = await _oAuthService.CheckAuthenticationAsync(); if (!authenticated) { return(Redirect(_oAuthService.GetAuthCodePath(new State( WebConfigurationManager.AppSettings[OAuth.WEBAPI_HOME_URI] )))); } //response.Content = new ObjectContent<AuthClientRespond>( // new AuthClientRespond() // { // redirect = !authenticated, // redirectUrl = _oAuthService.GetAuthCodePath(new State( // WebConfigurationManager.AppSettings[OAuth.HOME_URI] // )) // }, new JsonMediaTypeFormatter(), "application/json" //); else { return(View()); } }