Being redirected to login page from order status page even after logging in with Storefront API

StoneFlies
Shopify Partner
3 0 0

I'm building a custom storefront using the storefront api while still using as much traditional routing as possible.

I'm logging my users in via the `customerAccessTokenCreate` Storefront API graphql mutation and a access token is being returned which I'm storing in localStorage. 

 

mutation customerAccessTokenCreate($input: CustomerAccessTokenCreateInput!) {
  customerAccessTokenCreate(input: $input) {
    customerAccessToken {
      accessToken
      expiresAt
    }
    customerUserErrors {
      code
      field
      message
    }
  }
}

 

 

I use this token to retrieve a customers orders from the `customer` query. Within the order I'm returning a customerUrl which looks something like this: https://<shop-name>.myshopify.com/account/orders/e29f857561d8793cfa42606297a0216f  

 

query Orders($customerAccessToken: String!) {
  customer(customerAccessToken: $customerAccessToken) {
    orders(first: 250) {
      edges {
        node {
          id
          customerUrl
        }
      }
    }
  }
}

 


When I click this link I get redirected to a login page like the backend hasn't registered that a user has been logged in.

What am I doing wrong here please? I appreciate that the access token only authenticates the queries I'm running on the frontend, but how can I tell the route guard to let me past if I'm not doing the more traditional login? Could I add the access token to the URL?

Reply 1 (1)

StoneFlies
Shopify Partner
3 0 0

Looks like for web users MultiPass is the only way?

https://community.shopify.com/c/shopify-apis-and-sdks/storefront-weburl-checkout-logged-in/m-p/575214#M38571

https://github.com/Shopify/js-buy-sdk/issues/561#issuecomment-421013281