You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which had some corresponding code behind code provided by Auth- to login and logout.
using Auth0.OidcClient;
using IdentityModel.OidcClient.Browser;
using IdentityModel.OidcClient;
namespace MyApp.MauiControls;
public partial class AuthZ : ContentView
{
Auth0Client client = new Auth0Client(new Auth0ClientOptions
{
Domain = "***",
ClientId = "***",
RedirectUri = "myapp://callback",
PostLogoutRedirectUri = "myapp://callback",
Scope = "openid profile email"
});
public AuthZ()
{
InitializeComponent();
}
private async void OnLoginClicked(object sender, EventArgs e)
{
var extraParameters = new Dictionary<string, string>();
var audience = ""; // FILL WITH AUDIENCE AS NEEDED
if (!string.IsNullOrEmpty(audience))
extraParameters.Add("audience", audience);
var result = await client.LoginAsync(extraParameters);
DisplayResult(result);
}
private async void OnLogoutClicked(object sender, EventArgs e)
{
BrowserResultType browserResult = await client.LogoutAsync();
if (browserResult != BrowserResultType.Success)
{
ErrorLabel.Text = browserResult.ToString();
return;
}
LogoutBtn.IsVisible = false;
LoginBtn.IsVisible = true;
HelloLabel.Text = $"Hello, World!";
ErrorLabel.Text = "";
}
private void DisplayResult(LoginResult loginResult)
{
if (loginResult.IsError)
{
ErrorLabel.Text = loginResult.Error;
return;
}
LogoutBtn.IsVisible = true;
LoginBtn.IsVisible = false;
HelloLabel.Text = $"Hello, {loginResult.User.Identity.Name}";
ErrorLabel.Text = "";
}
}
When I click the Login button, i can see Chrome browser attempt to open, then the entire emulator crashes!!?
What's really putting me off using Uno Platform from this is the amount of time I'm going to need to spend trying to integrate libraries that would just work within .Net Maui that most providers are now supporting with sdks.
Now, i can also see that Uno Platform has support for authentication but the custom and oidc routes (which may work with Auth0 with some fiddling) appear to require the client secret on the app side, which I won't be doing.
Has anyone else successfully integrated an authz provider like Auth0 into Uno Platform, and if so could i get some pointers as to what i'm doing wrong here, thanks
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I've spent a few hours on this and could not get Auth0 integrated with Uno Platform despite trying a few options.
Auth0 (Okta) is a very common authz provider and it provides a number of sdks for native applications, but not Uno Platform.
https://auth0.com/docs/quickstart/native#native
The closest I thought was .Net Maui, which led me to the whole business of using the MauiControls library so I could use the Auth0 provided nuget libary for Maui.
https://platform.uno/docs/articles/external/uno.extensions/doc/Learn/Maui/MauiOverview.html?tabs=single-project
I'm working primarily on Android at present so figured out how to add a callback schema on the MainActivity in the head project so that was ok.
So i made an authz.xaml ContentView in my MauiControls project:
which had some corresponding code behind code provided by Auth- to login and logout.
When I click the Login button, i can see Chrome browser attempt to open, then the entire emulator crashes!!?
What's really putting me off using Uno Platform from this is the amount of time I'm going to need to spend trying to integrate libraries that would just work within .Net Maui that most providers are now supporting with sdks.
Now, i can also see that Uno Platform has support for authentication but the custom and oidc routes (which may work with Auth0 with some fiddling) appear to require the client secret on the app side, which I won't be doing.
https://platform.uno/docs/articles/external/uno.extensions/doc/Learn/Authentication/AuthenticationOverview.html
Has anyone else successfully integrated an authz provider like Auth0 into Uno Platform, and if so could i get some pointers as to what i'm doing wrong here, thanks
Beta Was this translation helpful? Give feedback.
All reactions