diff --git a/.changeset/beige-kids-build.md b/.changeset/beige-kids-build.md deleted file mode 100644 index af9da1480..000000000 --- a/.changeset/beige-kids-build.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@shopify/shopify-api': patch ---- - -Fix storefront header incorrectly setting private token as access token diff --git a/.changeset/tough-schools-know.md b/.changeset/tough-schools-know.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/tough-schools-know.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/lib/clients/graphql/__tests__/storefront_client.test.ts b/lib/clients/graphql/__tests__/storefront_client.test.ts index d21f8afaf..38b9f9ac3 100644 --- a/lib/clients/graphql/__tests__/storefront_client.test.ts +++ b/lib/clients/graphql/__tests__/storefront_client.test.ts @@ -96,7 +96,7 @@ describe('Storefront GraphQL client', () => { path: `/api/${shopify.config.apiVersion}/graphql.json`, data: QUERY, headers: { - [ShopifyHeader.StorefrontPrivateToken]: 'private_token', + [ShopifyHeader.StorefrontAccessToken]: 'private_token', }, }).toMatchMadeHttpRequest(); }); diff --git a/lib/clients/graphql/storefront_client.ts b/lib/clients/graphql/storefront_client.ts index ccc1599a2..22a91969c 100644 --- a/lib/clients/graphql/storefront_client.ts +++ b/lib/clients/graphql/storefront_client.ts @@ -41,16 +41,13 @@ export class StorefrontClient extends GraphqlClient { protected getApiHeaders(): HeaderParams { const sdkVariant = LIBRARY_NAME.toLowerCase().split(' ').join('-'); - const privateToken = - this.storefrontClass().config.privateAppStorefrontAccessToken; - const tokenHeaderParam = - privateToken === undefined - ? {[ShopifyHeader.StorefrontAccessToken]: this.storefrontAccessToken} - : ({ - [ShopifyHeader.StorefrontPrivateToken]: privateToken, - } as HeaderParams); + return { - ...tokenHeaderParam, + [ShopifyHeader.StorefrontAccessToken]: this.storefrontClass().config + .isCustomStoreApp + ? this.storefrontClass().config.privateAppStorefrontAccessToken || + this.storefrontAccessToken + : this.storefrontAccessToken, [ShopifyHeader.StorefrontSDKVariant]: sdkVariant, [ShopifyHeader.StorefrontSDKVersion]: SHOPIFY_API_LIBRARY_VERSION, }; diff --git a/lib/types.ts b/lib/types.ts index 3d81edc14..59b1d9c6a 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -27,7 +27,6 @@ export enum ShopifyHeader { Topic = 'X-Shopify-Topic', WebhookId = 'X-Shopify-Webhook-Id', StorefrontAccessToken = 'X-Shopify-Storefront-Access-Token', - StorefrontPrivateToken = 'Shopify-Storefront-Private-Token', StorefrontSDKVariant = 'X-SDK-Variant', StorefrontSDKVersion = 'X-SDK-Version', }