How to use the @commercetools/sdk-middleware-auth.createAuthMiddlewareForRefreshTokenFlow function in @commercetools/sdk-middleware-auth

To help you get started, we’ve selected a few @commercetools/sdk-middleware-auth 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 commercetools / nodejs / integration-tests / sdk / auth-middleware.it.js View on Github external
.then(({ body: cart }) => {
          expect(cart).toHaveProperty('anonymousId', anonymousId)

          // fetch another token with the refresh token flow
          const userConfig = {
            ...apiConfig,
            refreshToken: tokenObject.refresh_token,
            fetch,
          }
          const client = createClient({
            middlewares: [
              createAuthMiddlewareForRefreshTokenFlow(userConfig),
              httpMiddleware,
            ],
          })
          return client.execute({
            // fetch all carts tied to the anonymous token, if cart is present,
            // then the cart belongs to the same anonymousId
            uri: `/${projectKey}/me/carts`,
            method: 'GET',
          })
        })
        .then(