0

我被困在 shopify 会话令牌身份验证中。我正在使用烧瓶作为后端。这是前端代码:

<script>
        var AppBridge = window['app-bridge'];
        var utils = window['app-bridge-utils']
        var Redirect = AppBridge.actions.Redirect;

        const permissionUrl =
            "/oauth/authorize?client_id={{ api_key }}&scope={{ scopes }}&redirect_uri={{ redirect_uri }}";

        if (window.top == window.self) {
            window.location.assign("https://{{ shop }}/admin" + permissionUrl);

        } else {
            const app = AppBridge.createApp({
                apiKey: "{{ api_key }}",
                shopOrigin: "{{ shop }}"
            });
            console.log(app)
            //try {
                const sessionToken = utils.getSessionToken(app);
                sessionToken.then((successMessage) => {
                    console.log("Yay! " + successMessage);
                    if (successMessage === undefined)
                        Redirect.create(app).dispatch(Redirect.Action.ADMIN_PATH, permissionUrl);
                    else {
                        const fetch = utils.authenticatedFetch(app);
                        console.log("Fetch: " + fetch);
                    }
                });
       </script>

我拿到令牌后不知道该怎么办,我应该将它发送到烧瓶吗?如何?

4

0 回答 0