Replies: 2 comments
-
Hi @mezdelex, before we try to dig into how to adjust the Uno wrapper for oidc, are you able to get any of the oidc samples or a basic non-uno based application to authenticate? If you are, we should be able to use that to work out what we need to modify within uno. |
Beta Was this translation helpful? Give feedback.
-
So I added private async Task AuthenticateAsync()
{
IsLoading = true;
try
{
var client = new OidcClient(new OidcClientOptions
{
Authority = _configuration["Oidc:Authority"],
ClientId = _configuration["Oidc:ClientId"],
ClientSecret = _configuration["Oidc:ClientSecret"],
Policy = new Policy
{
Discovery = new DiscoveryPolicy
{
ValidateEndpoints = true,
ValidateIssuerName = true,
AdditionalEndpointBaseAddresses = _configuration.GetSection("Oidc:AdditionalEndpointBaseAddresses").Get<string[]>()
}
},
RedirectUri = _configuration["Oidc:RedirectUri"],
Scope = _configuration["Oidc:Scope"]
});
var result = await client.LoginAsync();
if (!result.IsError)
Store.UserName = result.AccessToken;
}
catch (Exception ex)
{
Store.UserName = ex.Message;
}
} Considering the issue, it would be necessary to expose at least these properties in the wrapper. I can't login yet because it threw no browser configured error, but that's another issue. I will keep the post updated with the complete process the moment everything works fine. |
Beta Was this translation helpful? Give feedback.
-
Hi, as the title suggest, I'm having issues with the Oidc Authentication wrapper since the expected behavior of what it wraps is not as it should be, I guess.
For reference, I created a project with
dotnet new unoapp -o Whatever -preset=recommended -platforms android ios --vscode
.I also followed this guide to add Oidc Authentication to the app: dotnet new unoapp
Then I have my
appsettings.development.json
like this:With the necessary info filled.
And this is the
LoginModel.cs
:And this is the code fragment that contains the login button at
LoginPage.xaml
:Ok, the thing is that if I use a
Oauth2 type of Authority /v2.0
in theappsettings
, the login process returns:"endpoint belongs to different authority" error
And if I use the
Oauth type of Authority
, the app registration at Azure by default, it returns the error:"issuer name does not match authority"
In both cases, I cannot use the wrapper as it is since it needs to be added some workaround to bypass those problems.
My questions is, where and how should I handle this problem in a Uno Platform way?
I've seen workarounds like this from Stackoverflow:
Or setting
"accessTokenAcceptedVersion": 2
in the app manifest, which I did, and in theory doing that together with Oauth2 type of Authority it should call the corresponding endpoints fromhttps://login.microsoftonline.com/<tenantId>/v2.0/.well-known/openid-configuration
but I get the same endoints not belonging error.Any suggestion will be appreciated.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions