refactor codeExchangeProxy to use same route and use it for refresh token as well

This commit is contained in:
Tyler Leonhardt
2021-05-28 10:35:43 -07:00
parent a6f4d96b82
commit 15616f8d93

View File

@@ -566,7 +566,8 @@ export class AzureActiveDirectoryService {
});
const proxyEndpoints: { [providerId: string]: string } | undefined = await vscode.commands.executeCommand('workbench.getCodeExchangeProxyEndpoints');
const endpoint = proxyEndpoints && proxyEndpoints['microsoft'] || `${loginEndpointUrl}${tenant}/oauth2/v2.0/token`;
const endpointUrl = proxyEndpoints?.microsoft || loginEndpointUrl;
const endpoint = `${endpointUrl}${tenant}/oauth2/v2.0/token`;
const result = await fetch(endpoint, {
method: 'POST',
@@ -602,7 +603,10 @@ export class AzureActiveDirectoryService {
let result: Response;
try {
result = await fetch(`https://login.microsoftonline.com/${tenant}/oauth2/v2.0/token`, {
const proxyEndpoints: { [providerId: string]: string } | undefined = await vscode.commands.executeCommand('workbench.getCodeExchangeProxyEndpoints');
const endpointUrl = proxyEndpoints?.microsoft || loginEndpointUrl;
const endpoint = `${endpointUrl}${tenant}/oauth2/v2.0/token`;
result = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',