Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Fix Client Credentials authorization header #140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/insomnia/src/network/basic-auth/get-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/network/o-auth-2/get-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? '')));
paulius-valiunas marked this conversation as resolved.
Show resolved Hide resolved
}

const response = await sendAccessTokenRequest(requestId, authentication, params, headers);
Expand Down