All things Shopify and commerce
I have created an embedded node-react app using Shopify-CLI. This is how its server.js file look like this
app.prepare().then(async () => {
const server = new Koa();
const router = new Router();
server.keys = [Shopify.Context.API_SECRET_KEY];
server.use(
createShopifyAuth({
async afterAuth(ctx) {
// Access token and shop available in ctx.state.shopify
const { shop, accessToken, scope } = ctx.state.shopify;
const host = ctx.query.host;
ACTIVE_SHOPIFY_SHOPS[shop] = scope;
token = accessToken;
const response = await Shopify.Webhooks.Registry.register({
shop,
accessToken,
path: "/webhooks",
topic: "APP_UNINSTALLED",
webhookHandler: async (topic, shop, body) =>
delete ACTIVE_SHOPIFY_SHOPS[shop],
});
if (!response.success) {
console.log(
`Failed to register APP_UNINSTALLED webhook: ${response.result}`
);
}
// // Redirect to app with shop parameter upon auth
ctx.redirect(`/?shop=${shop}&host=${host}`);
},
})
);
I want to get the permanent access token by making a post request to
POST https://{shop}.myshopify.com/admin/oauth/access_token
mentioned in documentation.
In your request, {shop} is the name of the merchant's shop and the following parameters must be provided in the request body:
Parameter Descriptionclient_id | The API key for the app, as defined in the Partner Dashboard. |
client_secret | The API secret key for the app, as defined in the Partner Dashboard. |
code | The authorization code provided in the redirect. |
But I don't know where exactly do I have to make this request.
I am trying to make this request just before ctx.redirect() in above code but it is throwing an error
InternalServerError: Missing parameter name at 5
I do not know if I am making any mistake in post request or am I making some other mistake.
Its been a week and I am stuck at this.
Could you please help me with this ?
Ajaysaini99, did you get to know how to get the token? Also looking into it. Thx.
Hi!
Have you managed to solve this? I'm facing the same challenge.
Thank you
User | RANK |
---|---|
68 | |
49 | |
36 | |
34 | |
29 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022