After install app i get access token and other data for auth, and i am need to redirect to home page. I DON`T use KOA-SHOPIFY-AUTH library. My code part:
router.get('/onInstall', (ctx, next) => {
const { shop } = ctx.request.query;
const redirectUri = `https://${ctx.request.headers.host}/onInstallFinish`;
console.log(redirectUri);
ctx.redirect(`https://${shop}/admin/oauth/authorize?client_id=${API_KEY}&scope=${API_SCOPE}&redirect_uri=${redirectUri}`);
next(ctx)
});
router.get('/onInstallFinish', (ctx, next) => {
const { shop, code } = ctx.request.query;
ACTIVE_SHOPIFY_SHOPS.shop = shop;
axios.post(`https://${shop}/admin/oauth/access_token`, {
client_id: API_KEY,
client_secret: API_SECRET,
code
}).then((response) => {
ACTIVE_SHOPIFY_SHOPS.accessToken = response.data.access_token;
const host = ctx.query.host;
ACTIVE_SHOPIFY_SHOPS.host = host;
console.log(shop);
ctx.redirect(`/?shop=${shop}&host=${host}`);
})
.catch((er
IFY_SHOPS.shop = shop;
});
directUri);
ctx.redirect(`https://${shop}/admin/oauth/authorize?client_id=${API_KEY}&scope=${API_SCOPE}&redirect_uri=${redirectUri}`);
next(ctx)
});
router.get('/onInstallFinish', (ctx, next) => {
const { shop, code } = ctx.request.query;
ACTIVE_SHOPIFY_SHOPS.shop = shop;
});