【发布时间】:2019-01-24 21:11:34
【问题描述】:
阅读文档here 和代码 sn-p 示例。这是否意味着持续检查用户是否登录到嵌入式应用程序或用于初始注册/登录过程?
另外,如果我已经在使用AppProvider 组件,这还需要吗?我知道AppProvider 处理初始化,根据他们的文档here。
这是他们文档中的示例:
import createApp from '@shopify/app-bridge';
import {Redirect} from '@shopify/app-bridge/actions';
const apiKey = 'API key from Shopify Partner Dashboard';
const redirectUri = 'whitelisted redirect URI from Shopify Partner Dashboard';
const permissionUrl = `/oauth/authorize?client_id=${apiKey}&scope=read_products,read_content&redirect_uri=${redirectUri}`;
// If the current window is the 'parent', change the URL by setting location.href
if (window.top == window.self) {
window.location.assign(`https://${shopOrigin}/admin/${permissionUrl}`)
// If the current window is the 'child', change the parent's URL with Shopify App Bridge's Redirect action
} else {
const app = createApp({
apiKey: apiKey,
shopOrigin: shopOrigin,
});
Redirect.create(app).dispatch(Redirect.Action.ADMIN_PATH, permissionUrl);
}
【问题讨论】:
-
你有没有想过这个问题?这是否意味着permissionUrl 应该是每个使用我们应用程序的商家(甚至那些已经安装它的商家)的入口点?有没有一种方法可以快速确定商家是否已经安装了您的应用程序来绕过这个,而只是创建(应用程序)?我唯一能想到的是做一个条件,我验证他们来自的初始 url 的 hmac,然后向 Shopify 管理 api 发出请求以查看他们的访问令牌是否有效;如果是这样,我将只创建(应用程序),但如果不是,那么我会将它们路由到 permissionUrl。