Add Auth0 Authentication to Blazor Hybrid Apps in .NET MAUI

Learn how to authenticate users of your .NET MAUI Blazor application using Auth0.
Read more…

:writing_hand:t2: Brought to you by @andrea.chiarelli

2 Likes

How did you like this post? Please share any comments or feedback with us on this thread

1 Like

The GitHub files have been deleted so there’s some work on going into the pull history to get the needed code.

Hi @sfernandez,
Sorry, I’m not sure what GitHub files are referring to :thinking:
As far as I can see, the sample project looks ok. Am I missing something?

@andrea.chiarelli , in the hyperlink text ‘this GitHub repo.’ linked to this sentence, it leads to a wrong link: https://github.com/auth0-blog/dotnet-maui-auth0-app/tree/main/Auth0, but the one you put in the comments works: dotnet-blazor-maui-auth0-app/Auth0 at main · auth0-blog/dotnet-blazor-maui-auth0-app · GitHub.

Hey @danilo.vetturini,
Welcome to the Auth0 community!

You are right, the link in the article is no longer working because it refers to a previous version of the repo. Thank you for reporting :pray:

I’m in the process of updating the current MAUI content because now we have a MAUI SDK, which simplifies significantly the code. This article still uses the previous approach and, as said, points to a repo that has been updated.
I have temporarily fixed the link now, but I plan to update the article in about a week or so.

Stay tuned!

Hello, is there an updated version of this article for .NET 8 available?

Is it possible to remember credentials and have the user automatically logged in on start-up? This is how it works in the iOS Native app using Auth0. Using this method I have to click Log-in and then hit “Continue” to allow it to sign in. I don’t have to retype my credentials again, but I would like to remove those two extra steps for users of my app.

Hey @adam16,
I have it in my plan but I can’t say when it will happen due to other priorities at the moment.

Maybe this article can help?

Yeah it works with .net 8 i just tested it. just follow the article and don’t FORGET to add platform specific code
like the WebAuthenticationCallbackActivity for android and the others.
otherwise you will get error like: “You must subclass your WebAuthenticationCallbackActivityAn etc…”

1 Like

Awesome! Thank you for your feedback :raised_hands:

I have tried to follow up this article, but I just cannot make it work with current Maui Blazor template. Apart from some things like non-existing “Main.razor” file there are other issues. I cannot find any mention here about “myapp” protocol and even after adding changes for this from other article (the one for Maui but without Blazor component) other issues arise.

It would be fantastic to have at least working example of current Maui Blazor application working with Auth0. Current state seems to be a lot of different places on your website - some of them are needed to be combined, other are contradictory or unclear. I have been trying to add Authentication for the simplest Maui Blazor app with those article and after a week - I have nothing that would be close to working. :frowning:

I’m sorry to hear that you have not been able to get a working Blazor MAUI app following this article. :slightly_frowning_face:
Unfortunately, it is based on .NET 7 and has not been updated to use the new Auth0 SDK, so I understand that it turns out to be very confusing in combination with the other articles.

There are plans to update this article, but right now I can’t say when that will happen.
I’ll ping you as soon as an updated version is published.
Sorry for the inconvenience and thanks for bringing this up :pray:

1 Like

Thank you very much. That would be greatly appreciated.

I see that there is a “This article is out of date” disclaimer at the top now. Any time line on when this will be updated?

Hi @adam16,
I plan to work on it in the next couple of weeks. Stay tuned!

This article has been updated to .NET 8 and now it uses the Auth0 .NET OIDC Client for MAUI SDK.

(cc: @adam16, @Al4ric, @bocarmg23, @danilo.vetturini)

1 Like

Thank you very much!