How to use the @shopify/app-bridge-utils.authenticatedFetch function in @shopify/app-bridge-utils

To help you get started, we’ve selected a few @shopify/app-bridge-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / next-gen-auth-app-demo / app / javascript / components / App.js View on Github external
export default function App() {
  const client = new ApolloClient({
    link: new HttpLink({
      credentials: 'same-origin',
      fetch: authenticatedFetch(window.app), // created in shopify_app.js
      uri: '/graphql'
    }),
    cache: new InMemoryCache()
  });

  return (
github Shopify / next-gen-auth-app-demo / app / javascript / utilities / protectedFetch.js View on Github external
export default function protectedFetch(appBridge) {
  const jwtFetch = authenticatedFetch(appBridge);

  return async (uri, options) => {
    const response = await jwtFetch(uri, options);
    if (invalidUserAccessTokenError(response)) {
      const { code, hmac, shop, timestamp } = await getAuthCode(appBridge);
      const callback_uri = `auth/shopify/callback?code=${code}&hmac=${hmac}&shop=${shop}&timestamp=${timestamp}`

      const callback_response = await jwtFetch(callback_uri);
      if (callback_response.status == 200) {
        return jwtFetch(uri, options);
      }
    } else {
      return response;
    }
  };
}

@shopify/app-bridge-utils

**[Join our team and work on libraries like this one.](https://www.shopify.ca/careers)**

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages