Skip to content

Commit f5caae2

Browse files
committed
fix(js-api-client): allow auto fetch shop api token with static auth token in the configuration
1 parent 4bdcd79 commit f5caae2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@crystallize/js-api-client",
33
"license": "MIT",
4-
"version": "2.3.0",
4+
"version": "2.3.1",
55
"author": "Crystallize <[email protected]> (https://crystallize.com)",
66
"contributors": [
77
"Sébastien Morel <[email protected]>",

src/core/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,12 @@ function shopApiCaller(configuration: ClientConfiguration, options?: CreateClien
163163
let shopApiToken = configuration.shopApiToken;
164164
return async function callApi<T>(query: string, variables?: VariablesType): Promise<T> {
165165
if (!shopApiToken && options?.shopApiToken?.doNotFetch !== true) {
166+
//static auth token is not enough for shop api token retrieval
167+
const { staticAuthToken, ...withoutStaticAuthToken } = configuration;
166168
const headers = {
167169
'Content-type': 'application/json; charset=UTF-8',
168170
Accept: 'application/json',
169-
...authenticationHeaders(configuration),
171+
...authenticationHeaders(withoutStaticAuthToken),
170172
};
171173
const response = await fetch(apiHost(configuration)([`@${identifier}`, 'auth', 'token'], 'shop-api'), {
172174
method: 'POST',

0 commit comments

Comments
 (0)