App reviews, troubleshooting, and recommendations
Hi guys,
I want to use cron job for some purpose but my query is how can I create the session for fetching data from Shopify?
Any help would be really appreciated.
Thank in advance:)
Girish | Shopify Expert
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- My Shopify Apps: App Store | Looking for a solution to a problem in your store? Send me an email
Hi @Girish_Rajwani,
After you install a Shopify app you will have an access_token. You can use that in your API calls when running your cron job.
So install a custom app or create a private app, then grab the access_token and start making calls to the Admin API.
Best,
Sam - Owner / Lead Developer
Achieve Applabs
Hey Sam,
Thanks for the reply. The app is public as i am not making for any specific client.
So will it work in public app?
Also, what would you suggest , cron job every 24 hours or Webhook when everytime order is placed?
Thanks
Girish | Shopify Expert
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- My Shopify Apps: App Store | Looking for a solution to a problem in your store? Send me an email
Hi @Girish_Rajwani,
Yes should work the same for public apps.
chron job would fetch the access token from db then make API calls using a client.
Best,
Sam - Owner / Lead Developer
Achieve Applabs
Hi ,
which library to use to make session from access token ? can you please share link or sample code ?
Thanks
Girish | Shopify Expert
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- My Shopify Apps: App Store | Looking for a solution to a problem in your store? Send me an email
Hi @Girish_Rajwani I'm currently facing the same problem. Have you come up with a solution?
Hey @SaulSimonett
yes i found the solution and cron is working. kindly share proper error message or screenshot so that i can properly .
thanks.
Girish | Shopify Expert
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- My Shopify Apps: App Store | Looking for a solution to a problem in your store? Send me an email
Yes. I usually fetch data from the frontend after is authenticated. Then in the backend I have the following code that creates a GraphQL client (it can be also REST) from the Frontend session.
function getApiClient(res) {
return new shopify.api.clients.Graphql({
session: res.locals.shopify.session,
});
}
How did you create the session from the CronJob to fetch data from the API?
Thanks.
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