阅读文档known issues和代码片段示例。这是为了一致检查用户是否已登录嵌入式应用程序或用于初始注册/登录过程吗?
此外,如果我已经在使用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);
}
答案 0 :(得分:1)
我发现在实施oauth旅程几周后,对它的使用也感到困惑。
但是现在我知道我将在用户将要使用一项功能的场景中使用它们的示例,该功能需要用户之前从未授予过该应用程序的权限,而我需要将其重定向到授权页面。我尝试了一个简单的重定向,但是由于仍在iframe中,因此禁止加载管理页面。