Learn · Mail on Windows
How “Sign in with Google” works in a desktop app
Why the browser opens, and why that's safer.
Desktop apps sign in to Google and Microsoft with OAuth. The app opens the provider's page in your own browser, where you're likely signed in already. You approve there, and the browser hands the app a sign-in through a short-lived address on your own PC (127.0.0.1).
The app never sees your password, and a one-time code (PKCE) means the sign-in only works for the app that asked. You can take access back any time from your Google or Microsoft account's security page.