fix: restore support for custom MS graph API url

relates to #16361

Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
Heikki Hellgren
2023-02-20 09:20:42 +02:00
parent f0ad59fb1a
commit 2c234a8932
3 changed files with 8 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-msgraph': patch
---
properly support custom graph api URL
@@ -53,7 +53,7 @@ describe('MicrosoftGraphClient', () => {
expect(await response.json()).toEqual({ value: 'example' });
expect(tokenCredential.getToken).toHaveBeenCalledTimes(1);
expect(tokenCredential.getToken).toHaveBeenCalledWith(
'https://graph.microsoft.com/.default',
'https://other.example.com/.default',
);
});
@@ -218,8 +218,9 @@ export class MicrosoftGraphClient {
headers?: Record<string, string>,
): Promise<Response> {
// Make sure that we always have a valid access token (might be cached)
const urlObj = new URL(url);
const token = await this.tokenCredential.getToken(
'https://graph.microsoft.com/.default',
`${urlObj.protocol}//${urlObj.hostname}/.default`,
);
if (!token) {