Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
{ "client_id":"", "client_secret":"", "code":"" } https://test-app.myshopify.com/admin/oauth/access_token
when I am hitting API to this endpoint for getting an offline access token showing an error that says The authorization code was not found or was already used.
app.get("/auth/callback", async (req, res) => { try { console.log("redirectUrl", req); const session = await Shopify.Auth.validateAuthCallback( req, res, req.query ); const host = req.query.host; const code = req.query.code app.set( "active-shopify-shops", Object.assign(app.get("active-shopify-shops"), { [session.shop]: session.scope, }) ); const response = await Shopify.Webhooks.Registry.register({ shop: session.shop, accessToken: session.accessToken, topic: "APP_UNINSTALLED", path: "/webhooks", }); if (!response["APP_UNINSTALLED"].success) { console.log( `Failed to register APP_UNINSTALLED webhook: ${response.result}` ); } // Redirect to app with shop parameter upon auth res.redirect(`/?shop=${session.shop}&host=${host}&code=${code}`); } catch (e) { } } });
taking code from the redirect URL and sent to iframe and posting API from the next.js web app showing error like this I can't be able to find where the code is used in my code or it is a backend issue. currently, I'm using access Token from the app to connect to Shopify. is any refresh token available to refresh the token. we need an offline token that never expires. if any replay are welcome need some hints