-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Updating WebAuthbrowser to latest form winuiex
- Loading branch information
1 parent
79444f7
commit 816d27c
Showing
7 changed files
with
235 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Uno.Extensions.Authentication.Oidc/WebAuthenticatorBrowser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
| ||
using IdentityModel.OidcClient.Browser; | ||
using System.Diagnostics; | ||
|
||
namespace Uno.Extensions.Authentication.Oidc; | ||
|
||
public class WebAuthenticatorBrowser : IBrowser | ||
{ | ||
public async Task<BrowserResult> InvokeAsync(BrowserOptions options, CancellationToken cancellationToken = default) | ||
{ | ||
try | ||
{ | ||
#if WINDOWS | ||
var userResult = await WinUIEx.WebAuthenticator.AuthenticateAsync(new Uri(options.StartUrl), new Uri(options.EndUrl)); | ||
var callbackurl = $"{options.EndUrl}/?{string.Join("&", userResult.Properties.Select(x => $"{x.Key}={x.Value}"))}"; | ||
return new BrowserResult | ||
{ | ||
Response = callbackurl | ||
}; | ||
#else | ||
var userResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, new Uri(options.StartUrl), new Uri(options.EndUrl)); | ||
|
||
return new BrowserResult | ||
{ | ||
Response = userResult.ResponseData | ||
}; | ||
#endif | ||
} | ||
catch (Exception ex) | ||
{ | ||
Debug.WriteLine(ex); | ||
return new BrowserResult() | ||
{ | ||
ResultType = BrowserResultType.UnknownError, | ||
Error = ex.ToString() | ||
}; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.