Merge pull request #16450 from drodil/graph_token_refix
fix: restore support for custom MS graph API url
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user