MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.2k stars 21.36k forks source link

Blazor Wasm Azure B2C Microsoft Account - Proof Key for Code Exchange is required for cross-origin authorization code redemption #114778

Open jumulr opened 1 year ago

jumulr commented 1 year ago

I am getting the PKCE error when following this how-to: https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory-b2c?view=aspnetcore-7.0

Already tried that but didn't work https://github.com/MicrosoftDocs/azure-docs/issues/90850

Can you help me please? Thanks a lot!


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Naveenommi-MSFT commented 1 year ago

@jumulr Thank you for bringing this to our attention. I've delegated this to content author @Rick-Anderson, who will review it and offer their insightful opinions.

guardrex commented 1 year ago

@Naveenommi-MSFT ... Rick isn't the content author for Blazor docs. I handle them.

Why is this opened here and not on the ASP.NET Core docs repo?

@jumulr ... We need more than that. You'll need to place a GH repro project up that demonstrates the failure and provide the error message(s) in your report.

jumulr commented 1 year ago

The exact error message is in the title, same as the mentioned issue without resolution.

To reproduce: create a vanilla Blazor WASM project using the latest Visual Studio and Net 7, follow the tutorial. It doesn’t work.

Please let me know if this is enough. By the way, what was the resolution for the previous issue if any?

guardrex commented 1 year ago

I see. That's cool. I'll see if I can reproduce the error here.

~We should be working this from our repo. Can you close this issue and open a new issue on our repo using the This Page feedback button + form at the bottom of ...~

https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory-b2c?view=aspnetcore-7.0

~WRT that other issue, this is the first that I've heard about any potential problem with the tutorial/ref topic that we keep. I'll take a look on Monday.~

I had a few minutes here, so I whipped out the test app that's based on our guidance, upgraded it to pre-release 8.0 (RC1) and ran it. I don't see a problem here. I was able to log my test user in.

You'll probably need to double check everything to see where your app config or Azure registration is broken.

This error ...

Proof Key for Code Exchange is required for cross-origin authorization code redemption

... seems strange to me. PKCE is used by MSAL 2.0, and our guidance is based on that lib, so I don't see why such an error would be thrown.

image

jumulr commented 1 year ago

Does my app and app registration in the external Microsoft account (B2C) need to be the same or something like that? If think it's related to the following settings (automatically generated)

image

guardrex commented 1 year ago

automatically generated

By what? That's not the correct configuration for an app generated by following the article's guidance.

The article shows examples of the configuration files ...

guardrex commented 1 year ago

~Moved to https://github.com/dotnet/AspNetCore.Docs/issues/30387.~

~@Naveenommi-MSFT ... You can close this issue. Thanks. 👍~

I've repurposed that issue to merely make our CLI guidance include a VS experience. I'm no longer looking at this problem on that issue because I can't reproduce the error here.

guardrex commented 12 months ago

Nevermind @Naveenommi-MSFT on closing this. I'm not working this error from our docs repo at this time. I can't reproduce this error, and I don't know why it's occurring for these users. The issue where this was first discussed at https://github.com/MicrosoftDocs/azure-docs/issues/90850#issuecomment-1096933233 was closed as resolved offline. @shwetamathur7 ... If you know what's happening here, could you let us know?