From a892610696bba7e130f60eff3b4a7a42994fc13e Mon Sep 17 00:00:00 2001 From: matheus Date: Mon, 18 Nov 2024 01:56:05 -0300 Subject: [PATCH] fix: adding suport to amazon JSON content type in the getToken request --- src/auth.ts | 4 ++-- src/enums.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/auth.ts b/src/auth.ts index 3d9b410..ba94541 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,6 +1,6 @@ import axios, { AxiosError, AxiosInstance } from 'axios'; -import { ContentTypes } from './enums'; +import { ContentTypes, jsonContentTypes } from './enums'; import { ZendeskRequestError } from './exceptions'; import { AuthBasic } from './interfaces'; import { AuthOptions, AuthOptionsZendesk } from './types'; @@ -124,7 +124,7 @@ export class BearerAuthZendesk extends BaseBearerAuth implements AuthBasic { httpCompleteResponse: true, contentType: contentType || ContentTypes.X_URL_ENCODED, data: - contentType === ContentTypes.JSON + jsonContentTypes.includes(contentType) ? JSON.stringify(this.authOptions.bearer.data) : this.authOptions.bearer.data, headers: this.authOptions.bearer.headers || {}, diff --git a/src/enums.ts b/src/enums.ts index 9d0ac80..6ddb70e 100644 --- a/src/enums.ts +++ b/src/enums.ts @@ -64,3 +64,5 @@ export enum ContentTypes { JSON = 'application/json', X_URL_ENCODED = 'application/x-www-form-urlencoded' } + +export const jsonContentTypes = ['application/json', 'application/x-amz-json-1.1']; \ No newline at end of file