Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shopify-app-remix] Authenicating public request 401 #409

Closed
huykon opened this issue Aug 21, 2023 · 5 comments
Closed

[shopify-app-remix] Authenicating public request 401 #409

huykon opened this issue Aug 21, 2023 · 5 comments

Comments

@huykon
Copy link

huykon commented Aug 21, 2023

Overview/summary

I'm following this guide to get shopify storefront data https://github.com/Shopify/shopify-app-js/tree/main/packages/shopify-app-remix#authenticating-public-requests, but my request is 401 now, I guess we need an authorization at header for request, what should I do now?

@TheRealFlyingCoder
Copy link

Hey, random question, but do your other Authenticate methods pass successfully?

I currently get 401 on everything but it's a new project

@huykon
Copy link
Author

huykon commented Aug 25, 2023

@TheRealFlyingCoder you have to using like this Shopify/shopify-api-js#936 (comment)

@paulomarg
Copy link
Contributor

Hi! In reality authenticate.public is actually geared towards checkout extension requests, so we'll be deprecating and renaming it to authenticate.public.checkout to avoid this kind of confusion.

Since the storefront API is public, you should be ok making requests to it as long as you have the access token. Right now, we don't provide a way to do that out of this package, but we'll be introducing it in the near future. I believe it will look something like this (definitely not final!):

const {storefront} = shopify.unauthenticated.storefront(shop, {publicAccessToken: <optional-public-token>});

In the meantime, I know it's not ideal, but you can use that comment you linked to and create a new shopifyAPI.clients.Storefront.

@TheRealFlyingCoder
Copy link

In the meantime, I know it's not ideal, but you can use that comment you linked to and create a new shopifyAPI.clients.Storefront.

I actually struggled to figure this one out yesterday, I gave up and installed a separate API package to pass the access token to so I could make requests separately to the Shopify app.

I'll check again today, but I feel like the reexported ShopifyApi was missing this functionality? 👀

@paulomarg
Copy link
Contributor

Hey folks! We've released a new version of the package that provides the unauthenticated Storefront context. Here is how you can use it in the latest versions: https://shopify.dev/docs/api/shopify-app-remix/v1/unauthenticated/unauthenticated-storefront

Since I believe this addresses the original issue, I'm going to close this. Feel free to open a new one if you still have problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants