App reviews, troubleshooting, and recommendations
I am currently developping a Shopify App using Remix.
Using this app, I want to able to run jobs that update product information.
Using the app, the user can create jobs, specifying informations about the products and type of task they want to perform. The jobs are saved in the DB connected to the App.
Then, every day (for example), I want to run a Serverless function (I was thinking of hosting it on Vercel) that:
- Gets the jobs the DB (not a problem)
- For each job, calls an API route that I created on the Remix app, that will be in charge of running the job (i.e updating store product information). (problem)
As of now, the requests fails because of the following code;
`const { admin } = await authenticate.admin(request);`
It seems that the request cannot be authenticated as admin.
Can you give me details about how I can authenticate the request or, if that's not possible, a different way to accomplish my goal ?
Many thanks,
Vincent
hi @TisaneFR,
You only need to authenticate as an admin when you want to get some data from Shopify's API (graphql /rest) that generally involves the store, customer or merchants. You can simply comment out that line if you don't need that kind of data access. However, if you do need to access the Shopify API, then you need to start the OAuth process from you're cloud function itself. Youre cloud function will have to start the OAuth process on behalf of a existing store to complete the process. You will need your client id (from you're app partner dashboard), access scopes, and redirect URL to make this request.
https://{shop}.myshopify.com/admin/oauth/authorize?client_id={your_client_id}&scope={requested_scopes}&redirect_uri={your_redirect_uri}&state={optional_state_parameter}
you can start the OAuth process from you're cloud function by hitting this endpoint on that store. Make sure that the redirect URL points to you're cloud function and that it's whitelisted in your partner dashboard account for that app. If the OAuth process is successful, Shopify will give you an access token with that redirect response. You can then make requests to the Shopify API on behalf of that store. Hope this answers you're question. Contact me if you want to discuss more about this topic.
Hello,
Thank you so much for your answer. I was able to make a request using the URL template you provided, but I can't find the access token with the response.
How should I proceed ?
Thank you,
Vincent
@BrainStation23
Can you help me with my previous question ?
Kind regards,
Vincent
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024