I'm having a pickle of a time getting access (pun intended) to user session accessTokens in the GetServerSideProps function so as to prepopulate props with page data on page load.
I am able to use the server's own offline access token for api calls to work, however I cannot access the logged-in app's scope and use
const session = await getSessionToken(app);
console.log("current session: ", session);
inside the GetServerSideProps function.
What am I missing?
I'm assuming this is a desired design pattern, rather than making all app queries after page load with session token.
Best,
rustcity
Hmm. K, so because the GetServerSideProps is running on the backend, its' neccessary to pull the session info off the koa context:
const { req, res } = ctx;
const sessionRetrieved = await Shopify.Utils.loadCurrentSession(
req,
res
);