Skip to content

Commit

Permalink
Update Maui.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dotMorten authored Sep 19, 2023
1 parent 7d64285 commit 282a04a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/concepts/Maui.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ To address that, explicitly reference the Windows App SDK package with the versi
</ItemGroup>
```

### Use WinUIEx's WebAuthenticator instead of .NET MAUI's
.NET MAUI does not support the WebAuthenticator out of the box on Windows. Instead you can use WinUIEx to get the same capability.
First in `\Platforms\Windows\App.xaml.cs`, add the `WebAuthenticator.CheckOAuthRedirectionActivation` to the App constructor and return if it returns `true`:
```cs
public App()
{
if (WinUIEx.WebAuthenticator.CheckOAuthRedirectionActivation())
return;
this.InitializeComponent();
}
```
When you want to perform an OAuth request, on Windows use WinUIEx's authenticator, instead of .NET MAUI's:
```cs
#if WINDOWS
var result = await WinUIEx.WebAuthenticator.AuthenticateAsync(new Uri(authUri), new Uri(redirectUri));
#else
var result = await WebAuthenticator.AuthenticateAsync(new Uri(authUri), new Uri(redirectUri));
#endif
````
Lastly, make sure you've registered the redirect uri-scheme in `Platforms\Windows\Package.appxmanifest`, as described in [WebAuthenticator](WebAuthenticator.md).


### Perform operations when Windows are created

Use the `ConfigureLifecycleEvents` to be notified of new windows getting created, which you can then extend with WinUIEx.
Expand Down

0 comments on commit 282a04a

Please sign in to comment.