Skip to content

Commit

Permalink
fix(platforms): explicitly request json response from coinbase API (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianHymer authored Dec 10, 2024
1 parent b18d319 commit 28b746e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions platforms/src/Coinbase/Providers/coinbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const requestAccessToken = async (code: string): Promise<string | undefin
console.log("error", e);
handleProviderAxiosError(e, "Coinbase access token", [clientSecret, code]);
}
console.log("tokenRequest", tokenRequest);

return tokenRequest?.data?.access_token;
};
Expand All @@ -84,7 +83,7 @@ export const verifyCoinbaseLogin = async (code: string): Promise<string | undefi
try {
// Now that we have an access token fetch the user details
userResponse = await axios.get("https://api.coinbase.com/v2/user", {
headers: { Authorization: `Bearer ${accessToken}` },
headers: { Authorization: `Bearer ${accessToken}`, Accept: "application/json" },
});
} catch (e) {
handleProviderAxiosError(e, "Coinbase user info", [accessToken, code]);
Expand Down
8 changes: 4 additions & 4 deletions platforms/src/Coinbase/__tests__/coinbase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe("Attempt verification", function () {
expect(mockedAxios.get).toBeCalledTimes(1);
// Check the request to get the user
expect(mockedAxios.get).toBeCalledWith("https://api.coinbase.com/v2/user", {
headers: { Authorization: "Bearer cnbstkn294745627362562" },
headers: { Authorization: "Bearer cnbstkn294745627362562", Accept: "application/json" },
});
});

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

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

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

expect(coinbasePayload).toEqual(
Expand Down

0 comments on commit 28b746e

Please sign in to comment.