I’ve google sign in working on Android, iOS and We...
# compose-desktop
g
I’ve google sign in working on Android, iOS and Web, and I was wondering, how can i use it too in a compose desktop app? 🤔 Do i need a “webview” and then intercept an “OK response”, close it and proceed with “app logic”? Anyone tried it? Thanks! 🙌
s
You're discouraged from using a webview for oauth. The best solution is either to embed an HTTP server in your app or install a custom protocol handler. I wrote a short article explaining how to do the first one here: https://levelup.gitconnected.com/oauth-in-compose-for-desktop-with-auth0-9990075606a1
🙏 1
g
Ok, made it work, and with a pretty simple approach in the end. • Registered my new redirect in Google Cloud Console “…./desktopapp” • Added to my SS app the logic to parse that redirect and respond with:
call.respondRedirect("<desktopapp://accesstoken>=${oauth.accessToken}")
• Added this configuration to the desktop-app: deeplink configuration • Finally, added the following code:
Copy code
Desktop.getDesktop().browse(URI("<http://localhost:8080/login?redirectLocation=desktopapp>"))
Desktop.getDesktop().setOpenURIHandler { event ->
    println("Open URI: " + event.uri)
}
and voi la, working as expected 😎
K 1