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.

Context influences requests (Response code 401 (Unauthorized))

See original GitHub issue

I am trying to create a public app.

When trying to create a product from inside my application it throws with : Response code 401 (Unauthorized)

However when I create a node script like this:

const Shopify = require('shopify-api-node')

const createProduct = async () => {
  const shopify = new Shopify({
    accessToken: ****,
    shopName: ****,
    apiVersion: '2020-04',
  })

  const res = await shopify.product.create({ title: 'Test' })
  console.log(res)
}

createProduct()

the product gets created successfully.

I tried to paste the exact same code in my application, but I still get the 401.

My application is built apollo-server-micro and running as an api route from next.js

If you need more info, I am happy to provide.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
lpincacommented, Aug 21, 2020

@BjoernRave this is a dirty workaround but it should work if you are not using the proxy functionality. In the module where you require auth0 for the first time do

const https = require('https');

const request = https.request;

const auth0 = require('auth0');

https.request = request;

Not sure if it breaks the auth0 module but it should not.

Edit: I’m confident it does not break auth0 if the proxy functionality is not used as per https://github.com/ngonzalvez/rest-facade/blob/v1.13.0/src/Client.js#L321-L323.

2reactions
lpincacommented, Oct 23, 2020

Yes, I ran npm ls agent-base after installing the latest version of auth0 and everything looks good. It should work without issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

403 Forbidden vs 401 Unauthorized HTTP responses
The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource....
Read more >
401 Unauthorized Error: What It Is and How to Fix It
The 401 Unauthorized Error is an HTTP response status code indicating that the client could not authenticate a request.
Read more >
Authentication Filters in ASP.NET Web API 2 - Microsoft Learn
If the server does not accept the credentials, it returns a 401 (Unauthorized) response. The response includes a Www-Authenticate header that ...
Read more >
Forbidden (403), Unauthorized (401), or What Else? - Auth0
How to use HTTP status code in the authorization context? When to use "401 Unauthorized" status code? When to use "403 Forbidden"?
Read more >
API limits – Asana
401, Unauthorized, A valid authentication token was not provided with the request, so the API could not associate a user with the request....
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