shopify-api-js
shopify-api-js copied to clipboard
Cannot complete OAuth process. Could not find an OAuth cookie for shop url:
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch @shopify/[email protected]
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/@shopify/shopify-api/dist/auth/oauth/oauth.js b/node_modules/@shopify/shopify-api/dist/auth/oauth/oauth.js
index 719f989..544abb6 100644
--- a/node_modules/@shopify/shopify-api/dist/auth/oauth/oauth.js
+++ b/node_modules/@shopify/shopify-api/dist/auth/oauth/oauth.js
@@ -52,7 +52,7 @@ var ShopifyOAuth = {
cookies.set(ShopifyOAuth.SESSION_COOKIE_NAME, session.id, {
signed: true,
expires: new Date(Date.now() + 60000),
- sameSite: 'lax',
+ sameSite: 'none',
secure: true,
});
query = {
I get this error in the oauth callback for the offline accessToken. I am doing the oauth in the top level window still I get this error. Am I doing something incorrectly or is it a bug in the library?
I'm getting the same error after I started using this in my Shopify.Context.Initiliaze:
SESSION_STORAGE: new Shopify.Session.MemorySessionStorage()
When I create the session storage using redis, it works.
I am using redis for session storage but still get this error.
I found out my app bridge redirect was incorrect and hence the auth was not happening in the top level window.
The following changes fixed the issue:
const redirect = Redirect.create(app);
redirect.dispatch(Redirect.Action.REMOTE, `${window.location.origin}${authUrlHeader}?shop=${shop}` ||`/auth?shop=${shop}`);
Does anyone know where I can find more about why we need a top-level window for auth to complete? It's not very clear as to why ?
I am also confused about it in general. However, in this particular case, the library is setting a cookie vie a set-cookie header and if the window is not top level then the browser rejects the cookie because of sameSite restrictions.
This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.
We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines
Thank you!
I'm facing the same issue can anyOne find a solution for this? My app is on Shopify CLI2.0