Open chrisgull opened 2 years ago
@chrisgull The .NET Core 3.1 console itself uses LoginAsync. I have no experience with UWP so I would appreciate you sharing a test project then I can take a closer look when time allows...
Hi Alex, thanks for quick reply. Attached is a simple UWP project that launches the code from ConsoleApp at startup, as a separate Task. Look in App.xaml.cs. You have to fill in your own _userid, _clientid, _clientsecret. I also tweaked _testfolder to a place I know an UWP app has access to. For me it crashes consistently in LoginAsync. I use VS2019. You might have to add some VS install items for UWP.
Other than that, THANK YOU for sharing this package, it's extremely helpful.
Lars LoginAsyncIssue2.zip
More info: This page says the UWP project need to declare a capability "privateNetworkClientService".
https://docs.microsoft.com/en-us/windows/uwp/networking/sockets
This is missing in the project above. Adding such capability does however not resolve the issue. I'm updating the above attached project to reflect this, the updated project is named LoginAsyncIssue2.zip.
OK, some research yielded this: you are using google.apis.auth, which does not support UWP. See https://github.com/googleapis/google-api-dotnet-client Might be tricky to convince Google to fix that. I'm going to try, but don't expect results.
I'm going to try Maui again, see if I can leave UWP behind soon. With some luck your package should work as is.
Ok and good luck :)
OK. Tried Maui. Maui sits on top of WinUI, which makes it a proper Win32 process. So the Google auth library works fine (but Maui is far from ready).
Not sure why you closed this issue - it's still an issue? Should I open a new issue?
I have re-opened it, but at the moment I've very little time to further investigate...
@chrisgull interested in what your use case is for UWP. I've tried it successfully it in both WPF and MAUI Hybrid (Blazor), FWIW.
I have re-opened it, but at the moment I've very little time to further investigate...
Keeping it open communicates that UWP is not at this time working (and my comments above tell others that it's a Google problem).
@chrisgull interested in what your use case is for UWP. I've tried it successfully it in both WPF and MAUI Hybrid (Blazor), FWIW.
Xamarin, which only supports UWP on windows. Net 6.0 Maui will change that, sitting on top of WinUI 3, which means none of the UWP sandbox limitations.
Hallo , if any one is interested in an Example of UWP authentication check the sampel app from google. https://github.com/googlesamples/oauth-apps-for-windows/tree/master/OAuthUniversalApp
and if you want the oaut working in Xamarin check this doc: https://codingforfun.de/xamarin-google-authentication-with-oauth/ github
i should be easily translated to maui!
ConsoleApp sample code works fine as a .NET Core 3.1 console app. Same code in an UWP app crashes deep in LoginAsync, seems async-related trying to access a disposed Socket object. I could post a project to reproduce but you already have the code, it's a pretty hard crash and burn. Let me know if you have questions. Lars