http-status-code-401

AngularJS - Handling refresh token?

落花浮王杯 提交于 2019-11-30 00:10:36
I'm building a SPA with AngularJS with communication to a service (JAVA). When user sends his username/pass, service sends back both: Acces token and Refresh token. I'm trying to handle: if I get response with status 401, send back refresh token and then send your last request again. I tried to do that with including $http, but angular doesn't let me include it in this interceptor. Is there any way to recreate the original request with this response parameter I'm recieving? Something like: I get 401 save my request if I have a refresh token send that refresh token on success resend my request

How to check for an HTTP status code of 401?

浪子不回头ぞ 提交于 2019-11-29 18:13:25
In one of the answers that I have received here , I encountered a problem of not knowing how to pass automatically through "Google App Engines" my ID and a password to a website, on which I am a registered user and have an account. A suggestion was given to me to "check for an HTTP status code of 401, "authorization required", and provide the kind of HTTP authorization (basic, digest, whatever) that the site is asking for". I don't know how to check for status code. Can anyone, please, tell me how to do it? +++++++++++++++++++++++++++++++++ Additional Information: If I use this way in Google

Setting authorization header in axios

隐身守侯 提交于 2019-11-29 14:44:09
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?parkCode=yell', config) .then((resp) => { console.dir(resp); }); and both return a 401. It works when I

customerrors for 401.2 in ASP.NET

梦想的初衷 提交于 2019-11-29 14:05:39
I successfully implemented role based authorization in ASP.NET. When a person does not have the needed role he gets to see an error page for 401.2 not authorized. What I would like to accomplish now is to have a custom 401 page in my application and have it redirected there via settings in the web.config. I tried this: <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="401" redirect="NoAccess.htm" /> </customErrors> But this does not get caught. Do I have to override it in IIS instead? I hope not as that would make getting things deployed harder. I ran

Java HttpURLConnection.getInputStream but get 401 IOException

允我心安 提交于 2019-11-29 13:53:47
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[] buffer = new char[1024]; while(true){ int noCharRead = reader.read(buffer); if (noCharRead == -1){ reader

Django login with wrong credentials returns 200 not 401

蹲街弑〆低调 提交于 2019-11-29 08:07:25
This is a pretty straight forward test, but I can't seem to get it right. I want to check which users can login and perform actions (it's part of a larger suite of tests), but the very first step causes some issues. class SuperUserTest(TestCase): def setUp(self): self.client = Client() self.su = User.objects.create_superuser('super','','the_correct_password') def test_su_can_login(self): response = self.client.post(reverse('django.contrib.auth.views.login'), {'username': 'super', 'password': 'the_wrong_password'}) self.assertEqual(response.status_code,401) # Success redirects to the homepage,

401 Unauthorized error web api mvc windows authentication

让人想犯罪 __ 提交于 2019-11-29 07:22:34
I am getting 401 unauthorized error . My web service is written in mvc . in IIS configured to use windows authentication. Below is screen shot of fiddler When I hit URL from browser it gives me popup window to enter user name and password. How can I avoid popup window? I am calling this web api from another window service. I suspect that the two web services may be hosted on the same server. In this case, the problem may be caused by the loopback check. In order to test, try referencing the service without using the fully qualified domain name and see if it works. If it does, use the following

Angular.js $http.post TypeError: Cannot read property 'data' of undefined

我们两清 提交于 2019-11-29 05:27:00
Angular.js v1.0.6 When making an $http.post and receiving a non 200 resposne (401 in this case) $http.post('http://localhost:3030/auth/login', { username: 'username', password: 'password' }) .success(function(data) { // Gets called on a 200 response, but not on a 401 console.log('success'); }) .error(function(err) { // Never gets called & dies with error described below. console.log('error'); }); Angular throws the following error: TypeError: Cannot read property 'data' of undefined at http://localhost:9000/components/angular/angular.js:8891:22 at wrappedCallback (http://localhost:9000

Making request to LinkedIn API results in 401

柔情痞子 提交于 2019-11-29 05:18:11
I am trying to make an API to à LinkedIn users profile using PHP . I've successfully registered my application and I've noted my API and Secret Key as well as listing my redirect url. The user starts on this page: index.php . This page contains a link to the linkedIn dialog box: <a href="https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=<?php echo $api_key ?>&state=<?php echo $state ?>&redirect_uri=<?php echo $redirect_uri ?>">Apply Now</a> When I click on this link I sign in to LinkedIn using my details and I am successfully redirected to application_form.php .

getting error java.io.IOException: Server returned HTTP response code: 401 for

為{幸葍}努か 提交于 2019-11-29 04:29:28
Iam trying to authenticate to https url , but iam getting exception . Below is code. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; public class Authenticate { /** * @param args */ public void authenticateUrl() { HostnameVerifier hv =