Comments (9)
When going through the /auth
it creates the session (I can see it in redis store) and then my axios requests (ajax) starts working (no more 401 error).
So now I catch this 401 error in axios and redirect to /auth
axiosInstance
.post("/my-rest?shop=" + shop, data)
.then(function (response) {
console.log("rep: ", response);
})
.catch(function (error) {
console.log("error: ", error);
const redirect = Redirect.create(app);
redirect.dispatch(Redirect.Action.APP, '/auth');
})
So the problem is not simple-koa-shopify-auth
. A coincidence I noticed the bug when I migrated to simple-koa-shopify-auth
Indeed the storeCallback is superflus (it was part of my experimenting).
Thanks for your support and thanks for the great simple-koa-shopify-auth
from simple-koa-shopify-auth.
Can you provide a bit more information?
- When does this happen, during the authentication flow (receiving the token), or during
verifyRequest
? - Is
storeSession
called? - Does the authentication flow work properly?
- Are you using
createShopifyAuth
andverifyRequest
correctly? (It's a little different than the old library.)
Hopefully these questions can help us get closer to the cause of the issue.
from simple-koa-shopify-auth.
- The context initialization is done in the
app.prepare().then(...)
storeSession
does not seem to be called- Authentication flow seems to be working but session not created
- I don't know if I am using correctly. I doubt I am using it correctly
I updated the question accordingly.
from simple-koa-shopify-auth.
@redochka Thank you for the code example. Does "inside afterAuth" get logged?
from simple-koa-shopify-auth.
And is the session token set on ctx.state.shopify
?
Also, I don't think you need to call storeSession
yourself after auth.
Edit: Nevermind, I thought the storeCallback
function that you have was storeSession
. What does that function do anyway?
from simple-koa-shopify-auth.
No, the "inside afterAuth" is not logged.
The redisStoreAccessToken.storeCallback
is storing the access token in a redis store.
from simple-koa-shopify-auth.
No, the "inside afterAuth" is not logged.
TheredisStoreAccessToken.storeCallback
is storing the access token in a redis store.
It seems strange that you have a storeCallback
and storeSession
function, since the session contains the access token and it appears to be the same thing.
Edit:
I'm confused with why you have two objects with a storeCallback
method.
const redisStoreAccessToken = await RedisStoreAccessToken();
const sessionStorage = await RedisStoreSession();
And you call storeCallback on the first one in the afterAuth
section and when registering the Shopify context you use the second one. I don't think it's necessary to call storeCallback yourself, because the Shopify Node API does that itself.
But since the message is not logged (assuming you still have it in your code), that means the authentication flow isn't working correctly and it's not calling the afterAuth
function. What happens when you go to the /auth
route?
from simple-koa-shopify-auth.
Actually it is partly an issue with this library, because I just realized I had changed the status code for invalid sessions from 403 to 401 (I think 401 Unauthorized
makes more sense than 403 Forbidden
, for when the session is invalid).
I failed to mention this change in the documentation, so I'm glad you found it.
from simple-koa-shopify-auth.
I've updated the documentation to include the note that this library uses status code 401 instead of 403.
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
- 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
- "Internal Server Error" message when first time installed an app, but app works fine after reload page. HOT 4
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.