Hi everyone,
I’ve been trying to set up the headless Customer Accounts API for a client and I’ve run into some trouble. I’ve managed to successfully generate an access_token using the /auth/oauth/token endpoint, but when I try and use the token to actually query the API, I get a 401 response saying the token is invalid.
I am following the docs here, which say to structure your requests like so:
const response = await fetch(
'https://shopify.com/
Here is the relevant request I am trying to make:
```javascript
const fetchCustomer = async (accessToken) => {
const response = await axios.post(
`${process.env.NEXT_PUBLIC_CUSTOMER_ACCOUNT_API_URL}/account/customer/api/unstable/graphql`,
{
query: `
query getCustomer {
customer {
id
}
}
`,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: accessToken,
},
}
);
const customer = cleanGraphQLResponse(response?.data?.data?.customer);
setState((prev) => ({ ...prev, customer }));
};