f2calv / CasCap.Apis.GooglePhotos

*unofficial* Google Photos REST API library for .NET projects.
MIT License
60 stars 11 forks source link

Doesn't work in UWP #79

Open chrisgull opened 2 years ago

chrisgull commented 2 years ago

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

f2calv commented 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...

chrisgull commented 2 years ago

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

chrisgull commented 2 years ago

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.

chrisgull commented 2 years ago

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.

chrisgull commented 2 years ago

I'm going to try Maui again, see if I can leave UWP behind soon. With some luck your package should work as is.

f2calv commented 2 years ago

Ok and good luck :)

chrisgull commented 2 years ago

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?

f2calv commented 2 years ago

I have re-opened it, but at the moment I've very little time to further investigate...

dcuccia commented 2 years ago

@chrisgull interested in what your use case is for UWP. I've tried it successfully it in both WPF and MAUI Hybrid (Blazor), FWIW.

chrisgull commented 2 years ago

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 commented 2 years ago

@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.

HolzetheKid commented 1 year ago

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!