Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I am new to Shopify, and I really can't find an answer to my dilemma.
I am trying to make a series of calls to the admin API (rest, GraphQL).
From what I understand from the documentation, every query abstraction needs a session object to get the accessToken and shop from like so.
const product = new shopify.rest.Product({session: session});
Since my app's scaffold was generated by the command:
npm init @shopify/app@latest
And after reading the generated code and trying to understand how everything works, the conclusion I got to is that the session object is constructed through the middleware
shopify.validateAuthenticatedSession()
and added to the res.locals, so on every request from the frontend with app-bridge using authenticatedFetch() to make sure it is authenticated.
What I am trying to do is to query the store products every set interval of times using cron-node to do some job outside of any route something like:
cron.schedule('* * * 1 * *', function () {
await titlesUpdator(session);
});
while titleUpdator() is a normal function that runs an admin API call, and no matter how long I searched there seems to be no straightforward way to construct a session object from the sessionStorage (for now it's an SQLite database).
Any help on how to tackle that would be greatly appreciated.
Thank you so very much.
I'm stuck on exactly the same thing.
Kryp, did you ever get a solution, or can anyone else help, please?
I'm also new to Shopify, and so far it's been absolutely impossible for me to find an answer to this simple question, although I'm happy to see that I'm not alone. The "shopify-api-js" docs (on Github) is not particularly clear on the subject. I found however that I can do what I want with only an access token, using the "shopify-api-node" library.
With this conversation I was able to make an offline / private app work: https://github.com/Shopify/shopify-api-js/issues/700#issuecomment-1410780918
To be clear, here are the values that I used: `apiKey`, `apiSecretKey` (this one confusingly corresponds to my access token in my case), and my shop name.
Learn 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, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025