diff --git a/packages/insomnia/src/network/basic-auth/get-header.ts b/packages/insomnia/src/network/basic-auth/get-header.ts index 4439aa96f..670bedde6 100644 --- a/packages/insomnia/src/network/basic-auth/get-header.ts +++ b/packages/insomnia/src/network/basic-auth/get-header.ts @@ -3,11 +3,10 @@ import type { RequestHeader } from '../../models/request'; export function getBasicAuthHeader( username?: string | null, password?: string | null, - encoding = 'utf8', + encoding: BufferEncoding = 'utf8', ) { const name = 'Authorization'; - const header = `${username || ''}:${password || ''}`; - // @ts-expect-error -- TSCONVERSION appears to be a genuine error + const header = `${username ?? ''}:${password ?? ''}`; const authString = Buffer.from(header, encoding).toString('base64'); const value = `Basic ${authString}`; const requestHeader: RequestHeader = { diff --git a/packages/insomnia/src/network/o-auth-2/get-token.ts b/packages/insomnia/src/network/o-auth-2/get-token.ts index 3a30eaa55..1bf82db1c 100644 --- a/packages/insomnia/src/network/o-auth-2/get-token.ts +++ b/packages/insomnia/src/network/o-auth-2/get-token.ts @@ -159,7 +159,7 @@ export const getOAuth2Token = async ( ...insertAuthKeyIf('client_secret', authentication.clientSecret), ]; } else { - headers.push(getBasicAuthHeader(authentication.clientId, authentication.clientSecret)); + headers.push(getBasicAuthHeader(encodeURIComponent(authentication.clientId ?? ''), encodeURIComponent(authentication.clientSecret ?? ''))); } const response = await sendAccessTokenRequest(requestId, authentication, params, headers);