Skip to content

Commit 28b746e

Browse files
authored
fix(platforms): explicitly request json response from coinbase API (#3121)
1 parent b18d319 commit 28b746e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

platforms/src/Coinbase/Providers/coinbase.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ export const requestAccessToken = async (code: string): Promise<string | undefin
7272
console.log("error", e);
7373
handleProviderAxiosError(e, "Coinbase access token", [clientSecret, code]);
7474
}
75-
console.log("tokenRequest", tokenRequest);
7675

7776
return tokenRequest?.data?.access_token;
7877
};
@@ -84,7 +83,7 @@ export const verifyCoinbaseLogin = async (code: string): Promise<string | undefi
8483
try {
8584
// Now that we have an access token fetch the user details
8685
userResponse = await axios.get("https://api.coinbase.com/v2/user", {
87-
headers: { Authorization: `Bearer ${accessToken}` },
86+
headers: { Authorization: `Bearer ${accessToken}`, Accept: "application/json" },
8887
});
8988
} catch (e) {
9089
handleProviderAxiosError(e, "Coinbase user info", [accessToken, code]);

platforms/src/Coinbase/__tests__/coinbase.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ describe("Attempt verification", function () {
197197
expect(mockedAxios.get).toBeCalledTimes(1);
198198
// Check the request to get the user
199199
expect(mockedAxios.get).toBeCalledWith("https://api.coinbase.com/v2/user", {
200-
headers: { Authorization: "Bearer cnbstkn294745627362562" },
200+
headers: { Authorization: "Bearer cnbstkn294745627362562", Accept: "application/json" },
201201
});
202202
});
203203

@@ -236,7 +236,7 @@ describe("Attempt verification", function () {
236236
expect(mockedAxios.get).toBeCalledTimes(1);
237237
// Check the request to get the user
238238
expect(mockedAxios.get).toBeCalledWith("https://api.coinbase.com/v2/user", {
239-
headers: { Authorization: "Bearer cnbstkn294745627362562" },
239+
headers: { Authorization: "Bearer cnbstkn294745627362562", Accept: "application/json" },
240240
});
241241
});
242242

@@ -267,7 +267,7 @@ describe("Attempt verification", function () {
267267
expect(mockedAxios.get).toBeCalledTimes(1);
268268
// Check the request to get the user
269269
expect(mockedAxios.get).toBeCalledWith("https://api.coinbase.com/v2/user", {
270-
headers: { Authorization: "Bearer cnbstkn294745627362562" },
270+
headers: { Authorization: "Bearer cnbstkn294745627362562", Accept: "application/json" },
271271
});
272272

273273
expect(coinbasePayload).toMatchObject({
@@ -297,7 +297,7 @@ describe("Attempt verification", function () {
297297
expect(mockedAxios.get).toBeCalledTimes(1);
298298
// Check the request to get the user
299299
expect(mockedAxios.get).toBeCalledWith("https://api.coinbase.com/v2/user", {
300-
headers: { Authorization: "Bearer cnbstkn294745627362562" },
300+
headers: { Authorization: "Bearer cnbstkn294745627362562", Accept: "application/json" },
301301
});
302302

303303
expect(coinbasePayload).toEqual(

0 commit comments

Comments
 (0)