Skip to content

Add support for OAuth2Manager #19787

Open

Description

@jeromelaban

If so there is a working OpenIddict-based sample https://github.com/Ecierge/openiddict-core/tree/apple-cryptokit/sandbox that provides this functionality for iOS and MacCatalyst.
It imports Apple CryptoKit and allows generating of RSA keys required for PKCE.

see https://learn.microsoft.com/en-us/windows/apps/develop/security/oauth2?tabs=csharp

Originally posted by @xperiandri in #19728

Activity

  1. added
    kind/enhancement
    help wanted
    on Mar 31, 2025
  2. ShreyasPathe commented on Aug 5, 2025

    @ShreyasPathe

    Hi, would love to work on this issue. Could you please assign it to me?

  3. DevTKSS commented on Aug 11, 2025

    @DevTKSS
    Contributor

    a working reference for the oAuthManager from WinAppSdk for WinUI3 app with the openIdDict used alongside:
    https://github.com/IlGalvo/WinUI3-OAuth2Manager-Sample/blob/main/Client/Client/MainWindow.xaml.cs

    I tryed to implement that in an Uno app to try it out, but beneath the fact that we do not get a non-device https:// callback then only an ms-app:// callback or similar protocol prefixed, I did fail on the Activation Arguments 🤔 not sure if we even do have the same on the non-windows targets?

    and for the linked sample of @xperiandri there, I did clone it locally and run into problems with the 6.x version of uno sdk packages especially for ios and as soon as I imported the SystemHttpIntegration package I think it was named, from the openIdDict there, we do have the problem of uno extensions is downgrading the google / xamarin activity packages so its all getting red / undetected and horribly not working at all.

    please see this Operating system integration notice of them for recognizing the limitations of exactly that package, as its known from them to not work on UWP which is to some point still kind of the uno base layer:
    https://documentation.openiddict.com/integrations/operating-systems

    Image

    https://documentation.openiddict.com/integrations/operating-systems#windows

    Image

    (marked the WinUI3 support column)

    not sure how that should then work in Uno if not even WinUI3 is fully supported at this point?
    maybe this would require a Asp Net core Server app also which would then catch the redirect_uri callback as THIS has oAuth support... all other are problematic with the systemIntegration package from my understanding

  4. DevTKSS commented on Aug 17, 2025

    @DevTKSS
    Contributor

    @jeromelaban linked one of the OpenIdDict Maintainers to this, hope this is okay with you?
    Maybe there is a chance that they have more info and can fix the problems with the SystemIntegration package.

    I created a current Uno Sdk using Branch with the setup of @xperiandri his sample code applyed:
    https://github.com/DevTKSS/DevTKSS.MyManufacturerERP/blob/openIdDict-Integration/src/DevTKSS.MyManufacturerERP/App.xaml.cs

    but remark that I did not change the code of him which looks to me like its "just" using oidc but would not allow e.g. Authorization Code flow from oAuth2 without discovery endpoint and so on and would require a code challange.

    Below that you can find what I came up with for WebAuthentication of uno, which is failing with

    Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
    Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
    

    latest code also provided on the equivalent Uno.Extensions Repo feature request for oAuth support:

    not sure if the WinUIEx_WebAuthenticator.cs code in the Uno Extensions could be enhanced too, as it seems to be used for oAuth but does still use id_token which would essentially not exist reading the oAuth standard documents.
    I added a PR on the extensions Repo also, to match the token Identifyer names to the official standard documents for oAuth and jwt (which seems to be the one which has that id_token instead of OAuth) and added more flexibility on the Options for the TokenCache, so we have Clean Seperation of Concerns (Web Auth Callback Functions should not suddenly care about options like token Cache belogingins) and a FluentBuilder for those in the WebAuthenticationBuilderExtensions:

  5. xperiandri commented on Aug 18, 2025

    @xperiandri
    Contributor

    @DevTKSS So did you succeed with the OpenIddict implementation?
    The main issue I had with Navigation Extensions is that they immediately activate the Window.
    Hence, contrary to WinUIEx_WebAuthenticator the second instance of the app appears too and closes with some delay.
    Kevin Chalet uses named pipes on Windows to unify the code. He told me that WinAppSDK does the same under the hood.

    And OpenIddict has a piece of code on startup which calls .Result on Task which causes a WASM app crash. That piece can be replaced with a custom implementation...

  6. DevTKSS commented on Aug 18, 2025

    @DevTKSS
    Contributor

    @xperiandri No, I was not successful with it so far. He told me that https would not be possible without a server that does allow device protocol which is, why I am now again trying to set up the server project "WebApi" in my repo with their docs code, but that would again just be another workaround 😟.

    I copied your code to a library project but its failing on the SystemHttpIntegration package because Uno does downgrade the Xamarin.Activity package as transient dependency for the ios and android target 🙄
    I would need to habe the AuthorizationCodeFlow woth pkce and token refresh enabled which I tryed to do on the server project already, but left the client uno app on the top of app.xaml.cs unchanged from your sample

    You can see my current status of that on the OpenIdDict-Integration Branch of my repo.

    Same time I remembered the WebView2 Control Support in Uno, but while the Windows version of it does indeed support "Basic authentication navigation" thats not eben mentioned as supported or not supported on the uno implemented views... The only thing I am trying to do is to send my user to that https auth Endpoint and let them redirect the user to the https://localhost:5001/etsy-auth-callback but as the oidc host builder part is above the uno ConfigBuilder loading of IOptions I seem to not able to get the options like always through this from appsettings or user-secrets?

    The WebAuthenticationProvider of uno does still not have an implementation for desktop wich would be the way Microsoft os telling to do besode the UriLauncher or WebView2 approach. Nothing seems to work even as workaround 😅 but windows throws me errors as soon as I use central loaded DataTemplates via ResourcesDictionary in app.xaml...

  7. xperiandri commented on Aug 18, 2025

    @xperiandri
    Contributor

    If you get OpenIddict Core server from sandbox as a project to a separate solution and replace project references with NuGets it should work.
    Also there is a samples OpenIddict repo, but I’m not sure how current they are.

  8. DevTKSS commented on Aug 19, 2025

    @DevTKSS
    Contributor

    @xperiandri I did replace the projectreferences with nugets right from the start..
    I think the main problem with using OpenIdDict in Uno as soon as you try to include Mobile targets in your app, is that downgrading of the Packages because uno references lower versions (why is that even? Why can't they upgrade them just like all the others?)

    . I did found samples but only not usable in uno options:

    What could work, but failing on non UI allowance of IWebAuthenticationBrokerProvider via DI until now (added a PR on the extensions repo for this which is looking for review)

    but only if I disable the webauthentication extension from uno...

  9. xperiandri commented on Aug 19, 2025

    @xperiandri
    Contributor

    @DevTKSS add

    <PackageVersion Include="Xamarin.AndroidX.Browser" Version="1.8.0.10" />
      <ItemGroup Condition="$(TargetFramework.Contains('-android'))">
        <PackageReference Include="Xamarin.AndroidX.Browser" />
      </ItemGroup>

    and failure go away

  10. xperiandri commented on Aug 19, 2025

    @xperiandri
    Contributor

    Bear in mind that auth on the desktop target may work only on Windows. Because in order to work on macOS the target must be -macos. And -desktop is just a plain .NET. And there are no crypto API in the plain .NET that can be used on macOS

  11. DevTKSS commented on Aug 20, 2025

    @DevTKSS
    Contributor

    @xperiandri my primary target would just be Desktop => Windows 11, but without the WinAppSdk, because of this persisting issue:

  12. github-actions commented on May 12, 2026

    @github-actions
    Contributor

    This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.

  13. added
    stale
    on May 12, 2026
  14. removed
    stale
    on May 12, 2026
  15. xperiandri commented on May 16, 2026

    @xperiandri
    Contributor

    @ShreyasPathe do you know how to setup CI that will apply Apple certificate necessary for Mac Catalyst app to access the KeyChain?

  16. github-actions commented on Oct 25, 2026

    @github-actions
    Contributor

    This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.

  17. added
    stale
    on Oct 25, 2026
  18. github-actions commented on Nov 5, 2026

    @github-actions
    Contributor

    This issue was closed because it had no activity for 10 days after being marked as stale. If you believe this is still relevant, feel free to reopen it or open a new issue with updated context.

  19. removed
    stale
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedkind/enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions