question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

discountCode.lookup() returns 401

See original GitHub issue

It looks like discountCode lookup method returns a redirection to the actual resource. Since the url we get forwarded to is not authenticated, we get a 401, which make sense.

This crash is quite easy to reproduce, simple look up any existing code. If you look for a non existing code, the request will return the following response without any redirection :

{
"errors": "Not Found"
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
szmarczakcommented, Jul 6, 2020

Yeah, that’s what exactly I mentioned in my previous comment. But Got should update the options with the credentials and for some reason it doesn’t. Will fix this ASAP.

0reactions
lpincacommented, Jul 6, 2020

@szmarczak here is a test to reproduce the issue.

const got = require('got');
const http = require('http');

const server = http.createServer(function (request, response) {
  if (request.url === '/redirect') {
    console.log(request.headers);
    response.statusCode = 302;
    response.setHeader('location', 'http://localhost:8080/');
    response.end();
    return;
  }

  console.log(request.headers);
  response.end();
});

server.listen(8080, async function () {
  await got('http://foo:bar@localhost:8080/redirect');
});

It seems this stopped working with got@10.

Read more comments on GitHub >

github_iconTop Results From Across the Web

401 Error: 5 Ways to Troubleshoot and Fix It - Hostinger
The 401 Unauthorized error is triggered by unauthenticated requests made to a WordPress web server. Learn how to identify and fix the issue....
Read more >
Solved: Discount code returns 401 unauthorized access after ...
The lookup endpoint returns a 303 with the location of the discount code. The HTTP client follows this and username:password is lost.
Read more >
How to Fix a 401 Unauthorized Error - Lifewire
A 401 Unauthorized error means the page you were trying to see needs a valid user ID/password before you can view it.
Read more >
How to Quickly Fix the 401 Unauthorized Error (5 Methods)
The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the ...
Read more >
Why am I getting a "401 Unauthorized" error in Maven?
According to this sonatype support page: "If you are receiving a 401 it is because maven is sending the wrong login credentials, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found