Skip to content

[Bug] Getting "Broker resonse returned error: The redirect URI doesn't match the uri generated with caller package name and signature" but only on some devices #6067

Description

@MihaMarkic

Library version used

4.83.+ at least

.NET version

.net 9.0-android

Scenario

PublicClient - mobile app

Is this a new or an existing app?

The app is in production, I haven't upgraded MSAL, but started seeing this issue

Issue description and reproduction steps

Describe the bug

My android app is live and I'm getting "Broker resonse returned error: The redirect URI doesn't match the uri generated with caller package name and signature" broker response but only on some devices. Majority seems working fine.
The exception occurs upon call to IPublicClientApplication.AcquireTokenSilent. I build the IPublicClientApplication using PublicClientApplicationBuilder and passing secrets through its methods.

To Reproduce

Call IPublicClientApplication.AcquireTokenSilent method.

Expected behavior

URI should match.

Actual Behavior

Getting an exception "Broker resonse returned error: The redirect URI doesn't match the uri generated with caller package name and signature"

Additional context

It happens only on some devices, unclear what is related to.
The question is, is there a way to get actual redirect URI that app compares?

Relevant code snippets

var builder = PublicClientApplicationBuilder
                .Create("ClientID")
                .WithTenantId("TenantId")
                .WithRedirectUri("MSBrokerRedirectUri")
                .WithBroker();
var pca = builder.Build();
var accounts = await pca.GetAccountsAsync();
try
{
    IAccount firstAccount = accounts.FirstOrDefault();
    var authResult = await pca.AcquireTokenSilent(Scopes, firstAccount).ExecuteAsync();
    // exception here ^^

Expected behavior

Redirect URI is correct.

Identity provider

Microsoft Entra External ID

Regression

No response

Solution and workarounds

None

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