question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AcquireTokenInteractive for AD B2C on .NET Core 3.0 WPF desktop client does not work

See original GitHub issue

Which Version of MSAL are you using ? MSAL 4.0.0

Platform .NET Core 3.0

What authentication flow has the issue?

  • Desktop / Mobile
    • Interactive
    • Integrated Windows Auth
    • Username Password
    • Device code flow (browserless)
  • Web App
    • Authorization code
    • OBO
  • Web API
    • OBO

Is this a new or existing app? This is a new app

Repro

// Creation of PublicClientApp
// Call to WithRedirectUri is commented out because that redirect URI cannot
// be added during app registration. 
public static IPublicClientApplication PublicClientApp { get; } = PublicClientApplicationBuilder.
    Create(ClientId).
    WithB2CAuthority(Authority).
    // WithRedirectUri("http://localhost").
    Build();

// ...

// Sign-in method logic
await App.PublicClientApp.AcquireTokenInteractive(App.ApiScopes).
    WithB2CAuthority(App.Authority).
    WithPrompt(Prompt.SelectAccount).
    ExecuteAsync();

Expected behavior Call to AcquireTokenInteractive should open default browser and prompt user for login credentials. After login should return focus to app.

Actual behavior AcquireTokenInteractive is throwing an exception: “Only loopback redirect uri is supported, but urn:ietf:wg:oauth:2.0:oob was found. Configure http://localhost or http://localhost:port both during app registration and when you create the PublicClientApplication object. See https://aka.ms/msal-net-os-browser for details”.

Additional context/ Logs / Screenshots Here is the Azure portal AD B2C tenant app registration screen for native client: link

On the AD B2C app registration I cannot add custom URI “http://localhost”.

So how can a .NET Core Desktop WPF app use interactive login with B2C? Are there any other options and examples?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
bgavrilMScommented, Apr 7, 2020

Just an update on this - B2C have now implemented support for http://localhost:<port> so AcquireTokenInteractive will work for the Identity Providers that allow this kind of redirect uri. They will support http://localhost (no port) soon.

4reactions
henrik-mecommented, Jan 14, 2020

@cswierczynski-diam Before supporting embedded browsers in the netcore target we have to make some structural changes to the library ensuring we can ship a netcore target which doesn’t have a dependency on WPF or Winforms. This work is currently in progress.

We have so far down prioritized providing the solution in the extensibility library as we want to make this feature part of the core library. The best option so far is to use the CustomWebUI approach as outlined by @bgavrilMS .

@jennyf19 any updates on the B2C timeline?

CC: @jmprieur @jennyf19

Read more comments on GitHub >

github_iconTop Results From Across the Web

To authenticate .NET Core 3.0 WPF desktop client with AD ...
I am creating a new WPF .NET Core 3.0 app, using Microsoft Identity Client (4.0.0) , and want to authenticate using AD B2C...
Read more >
Enable WPF desktop application options using Azure ...
Enable authentication options in a WPF desktop app by using Azure AD B2C · Preselect an identity provider · Specify the UI language...
Read more >
Integrate Azure AD B2C with ASP.NET MVC Web App
Part 3: This post will show how to build ASP.NET MVC App client app to consume ASP.NET Web API 2 protected by Azure...
Read more >
Azure AD B2C and MSAL with .NET Core WPF App and ...
When this exception occurs, the WPF App calls AcquireTokenInteractive API and allowing users to sign in instead of breaking the application.
Read more >
To authenticate .NET Core 3.0 WPF ... - appsloveworld.com
Coding example for the question To authenticate .NET Core 3.0 WPF desktop client with AD B2C, how to use the Default OS Browser?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found