-
Notifications
You must be signed in to change notification settings - Fork 84
EASDK auth flow is at risk of breaking in future versions of Chrome #65
Comments
We should update this asap |
Take a look at my module which is a drop-in solution for this. It uses the https://github.com/marekweb/shopify-express-oauth-redirect |
Thanks for that @marekweb. I think that ideally, we'd make this available in such a way that it's not specific to OAuth redirects, but rather give consumers a method to invoke (or perhaps an additional method) to perform a full-page redirect any time it's needed – the only other scenario I can think of off-hand would be a redirect to the RecurringApplicationCharge acceptance screen. |
Hi,
|
The problem with Sorry I don't have any links handy at the moment pointing to the discussions from the Chrome team, but I'll try to grab them when I have time. |
@jamiemtdwyer Good point about other the use cases for the redirect. The function in Here's a usage example. const createRedirectBody = require('shopify-express-oauth-redirect/create-redirect-body');
const redirectBody = createRedirectBody('https://example.com/arbitrary/url', 'shiny-trinkets.myshopify.com');
res.send(redirectBody); Here is the contents of <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base target="_top">
<title>Redirecting...</title>
<script type="text/javascript">
// If the current window is the 'parent', change the URL by setting location.href
if (window.top == window.self) {
window.top.location.href = "https://example.com/arbitrary/url";
// If the current window is the 'child', change the parent's URL with postMessage
} else {
normalizedLink = document.createElement('a');
normalizedLink.href = "https://example.com/arbitrary/url";
data = JSON.stringify({
message: 'Shopify.API.remoteRedirect',
data: { location: normalizedLink.href }
});
window.parent.postMessage(data, "https://shiny-trinkets.myshopify.com");
}
</script>
</head>
<body>
</body>
</html> |
Logging this now while it's fresh in my mind
https://github.com/Shopify/shopify-express/blob/master/routes/shopifyAuth.js#L37-L47
This code is at risk of breaking in a future version (65?) of Chrome, where Chrome will prevent redirects in the parent window.
The solution is to use a
postMessage
to the Shopify EASDK in order to perform the redirect. See the following example fromshopify_app
:https://github.com/Shopify/shopify_app/blob/3fb589d71bc03a11a8bb48bf87e613f6ce0210ea/app/assets/javascripts/shopify_app/redirect.js
The text was updated successfully, but these errors were encountered: