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

Authentication failure when calling app rest endpoint from theme extension #73

Open
MohamedBouzid opened this issue Feb 28, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@MohamedBouzid
Copy link

What is the problem you are facing?

Hello,

I'm trying to add a button in the theme.
Use case: Click on the button changes the value of a metafield attached to an order, and I'll get the new value of the metafield
shown on the page.

Solution I managed to put together so far:

  • Create a theme app extension: in the liquid containing the button, there's an api call to an endpoint (/app/xxx/status) like you are doing in the product reviews sample app.
  • Create an App proxy that exposes the above endpoint and defines the logic for it: calls the Admin API to get the metafield

Problem:

  • The request from the store is not going through: I have the authentication problem below :

https://mystore.myshopify.com/api/auth?oseid=xxxxxxx&shop=mystore.myshopify.com 404

Code:

I am using thee same logic as the generated code :

app.get("/api/products/count", async (_req, res) => {
const countData = await shopify.api.rest.Product.count({
session: res.locals.shopify.session,
});
res.status(200).send(countData);
});

and then calling this endpoint from the theme extension.

Question:

  • How can I see the logs of my app ?

  • How can I get this request go through ?

  • How to authenticate the request coming from the store to the app proxy then to the Admin API?

  • Is there an example to accomplish this ?

Regards

Describe the solution you'd like to see

I won't to see my app responding with 200 ok

Anything else?

No response

@MohamedBouzid MohamedBouzid added the enhancement New feature or request label Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant