From 4c86436fdfe6d92c8d8f325f2ed889d9cb651aa0 Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Fri, 27 Jan 2023 11:58:14 +0200 Subject: [PATCH] fix: use graph API target url for access token this fixes #15998 Signed-off-by: Heikki Hellgren --- .changeset/four-rivers-enjoy.md | 5 +++++ .../src/microsoftGraph/client.test.ts | 2 +- .../src/microsoftGraph/client.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/four-rivers-enjoy.md diff --git a/.changeset/four-rivers-enjoy.md b/.changeset/four-rivers-enjoy.md new file mode 100644 index 0000000000..b38babd8bd --- /dev/null +++ b/.changeset/four-rivers-enjoy.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-msgraph': patch +--- + +Fix MS Graph provider to use target URL for fetching access token diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts index 05693149d8..fdaa2a6a43 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.test.ts @@ -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', ); }); diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.ts index 26da0cb64b..321d784543 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/client.ts @@ -214,7 +214,7 @@ export class MicrosoftGraphClient { ): Promise { // 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) {