My Shopify app is ready to submit except the automated checks in the Partner dashboard don’t recognise that it uses session tokens.
My app is based on the Node.js template but with some updates. I use App Bridge on the frontend but I only use the built in fetch method, I never directly use the session tokens because I have no need for it. It says in the documentation that these are automatically authenticated when using App Bridge.
I’ve inspected my requests and they do indeed show session tokens.
Below are some snippets from my app code:
Frontend index.js:
import createApp from “@shopify/app-bridge”;
import {getSessionToken} from “@shopify/app-bridge/utilities”;const app = createApp({
apiKey: import.meta.env.VITE_SHOPIFY_API_KEY,
host: new URLSearchParams(window.location.search).get(“host”)
});// I’ve added this to try and force it to use a session token, hoping it would then recognise it
(async () => {
try {
// Initialize i18n
await initI18n();// Fetch session token const sessionToken = await getSessionToken(app); // Render the app const root = createRoot(document.getElementById("app")); root.render(<App />);
} catch (error) {
console.error(“Error during initialization:”, error);
}
})();
Component on the app page:
import {useAppBridge} from “@shopify/app-bridge-react”;
[…]
import {useQuery} from “react-query”;export function OrdersCard() {
const shopify = useAppBridge();[...] const { data: orders, refetch: refetchOrders, isLoading: isLoadingOrders, isRefetching: isRefetchingOrders, } = useQuery({ queryKey: ["orders"], queryFn: async () => { const response = await fetch("/api/orders"); return await response.json(); }, refetchOnWindowFocus: false, });
** backend initialisation
import {shopifyApp} from “@shopify/shopify-app-express”;
[…]const shopify = shopifyApp({
useOnlineTokens: true,
api: {
apiVersion: LATEST_API_VERSION,
restResources,
billing: billingConfig,
},
auth: {
path: “/api/auth”,
callbackPath: “/api/auth/callback”,
},
webhooks: {
path: “/api/webhooks”,
},
sessionStorage: new PostgreSQLSessionStorage(DATABASE),
});export default shopify;
I should add that I followed this guide to migrate to the newest version of @shopify/app-bridge-react. Migrate your app to Shopify App Bridge React 4.x.x
I even have another app that’s based on the same exact structure - it’s already approved and was approved before this automated check for session tokens came into effect. But for this one it even confirms in the app dashboard that session tokens are being used.
So what am I missing here or how can I make it recognise the use of session tokens?
I’d love to get this app out there as it has proven need for it.