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.
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025