http-status-code-401

Catch 401 Exception in Angular2

僤鯓⒐⒋嵵緔 提交于 2019-11-29 03:10:53
问题 When i try to connect to an unauthorized URL i get in Chrome: zone.js:1274 POST http://localhost:8080/rest/v1/runs 401 (Unauthorized) core.umd.js:3462 EXCEPTION: Response with status: 401 Unauthorized for URL: http://localhost:8080/rest/v1/runs The code of my Home Component is: import {Component, OnInit} from '@angular/core'; import {Run} from "../_models/run"; import {Http, Response} from "@angular/http"; import {RunService} from "../_services/run.service"; import {Observable} from "rxjs";

Chaining Express.js 4's res.status(401) to a redirect

流过昼夜 提交于 2019-11-29 02:32:08
问题 I'd like to send a response code of 401 if the requesting user is not authenticated, but I'd also like to redirect when the request was an HTML request. I've been finding that Express 4 doesn't allow this: res.status(401).redirect('/login') Does anyone know of a way to handle this? This might not be a limitation of Express, since I'm asking to essentially pass two headers, but I don't see why that should be the case. I should be able to pass a "not authenticated" response and redirect the

Eradicating 401 “Unauthorised” responses followed by 200 “Ok” responses

谁说胖子不能爱 提交于 2019-11-29 02:28:10
问题 I’ve got a situation with a large internal corporate web based application running ASP.NET 3.5 on IIS6 generating 401 “Unauthorised” responses followed by 200 “Ok” responses (as profiled by Fiddler). I’m aware of why this happening (integrated auth forcing the browser to resend credentials) but I’m looking for some thoughts on how to minimise or eradicate the situation. The application in question is running in the WAN with some users experiencing latency of up to 250ms so forcing a

Authorization in RESTful HTTP API, 401 WWW-Authenticate

不想你离开。 提交于 2019-11-29 02:10:28
问题 I'm creating a RESTful service to provide data to a web application. I have two related questions about this. 1. How to deal with unauthorized requests? I'm intending to respond to requests with the following codes: Is the resource open and found? 200 OK Do you need to be authenticated to access the resources? 401 Unauthorized Don't you have access to a category of resources? 403 Forbidden Do you have access to a category of resources, but not to this specific resource? 404 Not Found to

How to prevent IIS7 for handling HTTP status code 401?

别说谁变了你拦得住时间么 提交于 2019-11-28 23:31:25
I'm working my ASP.NET MVC 2 project. I create exception filter for catching unauthorized access exception that occur when user does not has permission to view some action. [CustomError(typeof(UnauthorizedAccessException), "Error", "UnauthorizedAccess")] public class MyController : BaseController { } After exception has been thrown, my filter will transfer to configured controller/action that is the following method. public ActionResult UnauthorizedAccess(ExceptionContext context) { Response.StatusCode = CustomHttpStatusCode.UnauthorizedUser; return View(model); } Finally, before ASP.NET

Turning off ASP.Net WebForms authentication for one sub-directory

天大地大妈咪最大 提交于 2019-11-28 23:22:08
I have a large enterprise application containing both WebForms and MVC pages. It has existing authentication and authorisation settings that I don't want to change. The WebForms authentication is configured in the web.config: <authentication mode="Forms"> <forms blah... blah... blah /> </authentication> <authorization> <deny users="?" /> </authorization> Fairly standard so far. I have a REST service that is part of this big application and I want to use HTTP authentication instead for this one service. So, when a user attempts to get JSON data from the REST service it returns an HTTP 401

401 Unauthorized: Access is denied due to invalid credentials

让人想犯罪 __ 提交于 2019-11-28 15:28:30
问题 I am using IIS Express to deploy MVC4 application. This website runs perfectly on same computer. But in Lan it gives me error 401. <authentication mode="Forms"> <forms loginUrl="~/" slidingExpiration="true" timeout="20"> </forms> </authentication> In home controller [HttpPost] [AllowAnonymous] public ActionResult Index(LoginModel model, string returnUrl) { } I am starting IIS server from command prompt in Administrator mode. IIS responds to the request with error 401 . Any clue? 回答1: I

Unable to get windows authentication to work through local IIS

自作多情 提交于 2019-11-28 15:20:49
So I've created a new ASP.NET MVC project using the intranet template. web.config contains the appropriate values (e.g. <authentication mode="windows"/> ). If I fire up the web app using the VS webserver, it all looks fine - the page shows my Windows domain and username and all. However, this works in Opera and Safari as well as IE and FF, which says to me it's not using Windows auth at all (since to the best of my knowledge this doesn't work in any browser except IE/FF). Next step is to get it working through local IIS. I create a hosts file entry pointing www.mysite.mydomain to 127.0.0.1. So

Setting authorization header in axios

喜欢而已 提交于 2019-11-28 08:11:35
问题 I have been trying to make a GET request to the National Park Service API with axios and have tried several ways to set my API key in the request header to no avail. Any assistance will be greatly appreciated. I have tried: axios.defaults.headers.common['Authorization'] = "MY-API-KEY"; axios.get('https://developer.nps.gov/api/v0/parks?parkCode=yell') .then((resp) => { console.dir(resp); }); and let config = {'Authorization': 'MY-API-KEY'}; axios.get('https://developer.nps.gov/api/v0/parks

Java HttpURLConnection.getInputStream but get 401 IOException

落爺英雄遲暮 提交于 2019-11-28 07:34:01
问题 I am writing a REST client for CouchDB in Java. The following code should be quite standard: this.httpCnt.connect(); Map<String, String> responseHeaders = new HashMap<>(); int i = 1; while (true){ String headerKey = this.httpCnt.getHeaderFieldKey(i); if (headerKey == null) break; responseHeaders.put(headerKey, this.httpCnt.getHeaderField(i)); i++; } InputStreamReader reader = new InputStreamReader(this.httpCnt.getInputStream()); StringBuilder responseBuilder = new StringBuilder(); char[]