icidasset / diffuse

A music player that connects to your cloud/distributed storage.
https://diffuse.sh
Other
808 stars 67 forks source link

Cannot login to Google Drive with new Tauri native build on Windows #351

Closed icidasset closed 2 years ago

icidasset commented 2 years ago

Issue with WebView from Microsoft (which Tauri uses) and Google I guess. More info here: https://github.com/MicrosoftEdge/WebView2Feedback/issues/1647

There's a few solutions:

  1. Create an app password on your Google account and login with that: https://support.google.com/accounts/answer/185833?hl=en
  2. Use Diffuse in the browser, add the source there and then come back to the native app. Remember that you can also export and import data via the settings screen.
  3. [Code] We override the user agent so Google thinks the browser is safe. This isn't super easy to do yet in Tauri, see https://github.com/tauri-apps/tauri/issues/4284
  4. [Code] We somehow open the browser from the Tauri app, and then do a redirect flow that opens back up the app? Don't know how to do that. Last I heard it wasn't possible to redirect to custom urls which would open up the app?
  5. [Code] We go back to Electron and stop using Tauri. Apparently I'm overriding the user agent as well in my Electron app.
icidasset commented 2 years ago

Ideally we'd do (4) using deep linking, but that's not released yet, see tracking issue: https://github.com/tauri-apps/tauri/issues/323

So we'll have to opt for (3) for the time being.

FabianLars commented 2 years ago

Just because i saw this issue linked in tauri#323. You can't actually use deep-linking via custom uri schemes for google, they don't allow that for win32 apps. Instead you need a localhost server :/

icidasset commented 2 years ago

Thanks for jumping in here @FabianLars ! That's good to know. I do have a localhost server for Tauri, but since my app uses indexedDB for storage, the storage is tied to the browser/app. I guess the way around that is by using Tauri storage? Or how do you see that working?

FabianLars commented 2 years ago

Yeah, alternatively you can send that value back to the frontend via tauri events https://tauri.app/v1/guides/features/events/

For what it's worth i started exploring a minimal approach to this issue here https://github.com/FabianLars/tauri-plugin-oauth/blob/main/src/lib.rs (don't mind the repo example, it's empty right now because i'm too lazy to actually set up oauth :/ ). Anyway, the way that one works is that it spawns a small tcplistener which you'd use as the redirect_uri handler. It's Rust only for now, but i'll try to add the js api somewhat soon. Kinda sounds like advertising lol, just wanna show you something you could potentially use as inspiration, because you currently won't get around writing some Rust code.

icidasset commented 2 years ago

Thanks again @FabianLars , really good pointers 👌 I will implement that sometime in the future 👍 Tracking in #353