Skip to content

[Bug] Connection to Microsoft Exchange REST API Based Powershell application with Broker is broken #4934

Description

@Balkoth

Library version used

4.64.1

.NET version

8.0.8

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, and I have upgraded to a new version of MSAL

Issue description and reproduction steps

I am trying to use the broker now, because i want to get the benefit of it instead of relying on the browser. But somehow the WithBorker call messes with the redirect URI. The redirect URI for this MICROSOFT APPLICATION can not be changed.

Relevant code snippets

// Fails with "AADSTS50011: The redirect URI 'ms-appx-web://Microsoft.AAD.BrokerPlugin/fb78d390-0c51-40cd-8e17-fdbfab77341b' specified in the request does not match the rediret URIs configureg for the application 'fb78d390-0c51-40cd-8e17-fdbfab77341b'.
string[] scopes = ["https://outlook.office365.com/.default"];
BrokerOptions options = new BrokerOptions(BrokerOptions.OperatingSystems.Windows);
options.Title = "Provide credentials";
IPublicClientApplication app =
  PublicClientApplicationBuilder.Create("fb78d390-0c51-40cd-8e17-fdbfab77341b")
  .WithAuthority(AzureCloudInstance.AzurePublic, tenantId)
  .WithRedirectUri("http://localhost")
  .WithBroker(options)
  .WithParentActivityOrWindow(GetConsoleOrTerminalWindow)
  .Build();
string accessToken = (await app.AcquireTokenInteractive(scopes).ExecuteAsync()).AccessToken;



// Succesfully fetches access token.
string[] scopes = ["https://outlook.office365.com/.default"];
IPublicClientApplication app = PublicClientApplicationBuilder.Create("fb78d390-0c51-40cd-8e17-fdbfab77341b")
  .WithAuthority(AzureCloudInstance.AzurePublic, tenantId)
  .WithRedirectUri("http://localhost")
  .Build();
string accessToken = (await app.AcquireTokenInteractive(scopes).ExecuteAsync()).AccessToken;

Expected behavior

I would expect this to just work.

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions