Merge pull request #16450 from drodil/graph_token_refix

fix: restore support for custom MS graph API url
This commit is contained in:
Ben Lambert
2023-02-20 17:12:20 +01:00
committed by GitHub
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) {