Skip to content

Commit

Permalink
Use Electron fetch or Node fetch for github-authentication to support…
Browse files Browse the repository at this point in the history
… proxies (microsoft#238149)

* Attempt to use Electron fetch for github-authentication

Also changes fallback from node-fetch to the built-in Node fetch

* Remove Content-Length header Electron compatibility

It looks like it was set incorrectly to the body contents anyways.
  • Loading branch information
devm33 authored Jan 17, 2025
1 parent a821bbf commit 87ed97d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 0 additions & 2 deletions extensions/github-authentication/src/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ async function exchangeCodeForToken(
headers: {
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': body.toString()

},
body: body.toString()
});
Expand Down
9 changes: 7 additions & 2 deletions extensions/github-authentication/src/node/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import fetch from 'node-fetch';

export const fetching = fetch;
let _fetch: typeof fetch;
try {
_fetch = require('electron').net.fetch;
} catch {
_fetch = fetch;
}
export const fetching = _fetch;

0 comments on commit 87ed97d

Please sign in to comment.