fix: Azure single-tenant SSO tokens are unable to refresh (#5551)

This commit is contained in:
Tom Moor
2023-07-11 18:59:28 -04:00
committed by GitHub
parent 5ae4834333
commit c56add74c6
3 changed files with 42 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
import fetch from "fetch-with-proxy";
import Logger from "@server/logging/Logger";
import { AuthenticationError, InvalidRequestError } from "../errors";
export default abstract class OAuthClient {
@@ -41,18 +42,22 @@ export default abstract class OAuthClient {
return data;
};
rotateToken = async (
refreshToken: string
async rotateToken(
_accessToken: string,
refreshToken: string,
endpoint = this.endpoints.token
): Promise<{
accessToken: string;
refreshToken?: string;
expiresAt: Date;
}> => {
}> {
let data;
let response;
try {
response = await fetch(this.endpoints.token, {
Logger.debug("utils", "Rotating token", { endpoint });
response = await fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
@@ -79,5 +84,5 @@ export default abstract class OAuthClient {
accessToken: data.access_token,
expiresAt: new Date(Date.now() + data.expires_in * 1000),
};
};
}
}