Comments (4)
Most likely it's in your load session function which gets called by the Shopify library when this library does the authentication, which causes the error to appear like it's coming from this package. I would add a try-catch block around your load session function to see if you can track down the error. Feel free to reopen this issue if you think it is an issue after all.
from simple-koa-shopify-auth.
Can this be reproduced in a development environment? I don't see anywhere where an id is being accessed in that part of the code, so it's either in the Shopify API library or in your code. Could you share the entire code you're using for the afterAuth
function? Unfortunately the error message isn't very helpful because it doesn't show where the id failed to be read.
The second error message is a Shopify server error, so I would assume it's because the session wasn't created properly or something.
from simple-koa-shopify-auth.
Just to confirm is this happening in development or production?
from simple-koa-shopify-auth.
This is happening in production, on a heroku deployment. And it might not be related to this library. I have done some digging, and it might be something to do with Shopify.Utils.loadCurrentSession
. So, probably can close the issue for now.
Also heres the full code for afterAuth -
server.use(
createShopifyAuth({
accessMode: "offline",
afterAuth: async (ctx) => {
const { shop, accessToken, scope } = ctx.state.shopify;
ACTIVE_SHOPIFY_SHOPS[shop] = scope;
ctx.query.token = accessToken;
// Store shop scopes and access token in firestore
await setDoc(doc(db, "tokens", shop), {
shop,
scope,
accessToken,
});
// Register all webhooks
const responses = await Promise.all(
webhooks.map(({ topic }) =>
Shopify.Webhooks.Registry.register({
topic,
shop,
accessToken,
path: "/webhooks",
})
)
);
responses.forEach((response, index) => {
const topic = webhooks[index].topic;
if (!response[topic].success) {
console.log(`Failed to register ${topic} webhook: ${response.result}`);
}
});
// NOTE: This currently doesnt work as heroku deployment restarts after 30 mins of inactivity and removes all existing data
// Deleting metafield on app reinstall if in production only
// if (!DEV && responses[0].APP_UNINSTALLED.success) {
// await deleteAllMetafield({ shop, accessToken });
// }
await Promise.all([
// Save the default settings object
saveDefaultSettings(shop, accessToken),
// Update the default store theme
updateTheme(shop, accessToken),
// Create a default collection
createCollection(shop, accessToken),
]);
ctx.redirect(`https://${shop}/admin/apps/${process.env.SHOPIFY_API_KEY}`);
},
})
);
from simple-koa-shopify-auth.
Related Issues (16)
- App bridge error after redirect in pages HOT 1
- Getting Context Initialize error HOT 4
- Latest version (2.1.4) doesn't use the host param when calling createApp in top-level-oauth-redirect.ts HOT 3
- ReferenceError: btoa is not defined HOT 5
- Supporting latest version of `@shopify/shopify-api` (version 6) HOT 13
- How to make it work with koa-mount? HOT 2
- Validate the request from Frontend
- Shopify graphQL proxy HOT 4
- LRUCache is not a constructor HOT 3
- Session creation is not working HOT 9
- The host is undefined HOT 12
- Reauth on Client Side HOT 2
- Add the ability to specify the host of the redirect url instead of ctx.host HOT 7
- "The app couldn't be loaded" error HOT 12
- Shopify.utils.validateShop has been deprecated HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-koa-shopify-auth.