fix: use graph API target url for access token

this fixes #15998

Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
Heikki Hellgren
2023-01-27 11:58:14 +02:00
parent 76b838a854
commit 4c86436fdf
3 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-msgraph': patch
---
Fix MS Graph provider to use target URL for fetching access token
@@ -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://example.com/.default',
);
});
@@ -214,7 +214,7 @@ export class MicrosoftGraphClient {
): Promise<Response> {
// Make sure that we always have a valid access token (might be cached)
const token = await this.tokenCredential.getToken(
'https://graph.microsoft.com/.default',
`${this.baseUrl}/.default`,
);
if (!token) {