Expand description
Google sign-in: authorization code + PKCE on a loopback redirect, token
exchange and refresh, and an access-token source for crate::GmailProvider.
pidge cannot ship a Google OAuth client for everyone (gmail.modify is a
restricted scope), so whoever runs pidge brings their own: a “Desktop
app” client locally (PIDGE_GOOGLE_CLIENT_ID / PIDGE_GOOGLE_CLIENT_SECRET),
a “Web application” client when hosted. Google treats a desktop client’s
secret as non-confidential, but its token endpoint still wants it.
Token persistence reuses pidge-client’s TokenBackend seam, so the
CLI’s keychain/file store (pidge_client::auth::LocalBackend) and the
hosted server’s secret store both work unchanged.
Structs§
- Google
Auth - Access tokens for one Google account, refreshed on demand and saved
back through
backend. - GoogleO
Auth Config - A Google OAuth client.
Constants§
- GOOGLE_
AUTH_ BASE - Google’s authorization endpoint.
- GOOGLE_
TOKEN_ URL - Google’s token endpoint.
- SCOPES
- The scopes pidge asks Google for, space separated.
Functions§
- authorize_
url - The URL to send the user’s browser to.
challengeis the PKCE S256 challenge,statethe CSRF nonce.access_type=offlineplusprompt=consentmakes Google return a refresh token every time. - exchange_
code - Exchange an authorization code for tokens; also returns the account’s address from the id token.
- refresh
- Refresh
tokens. Google usually leavesrefresh_tokenout of a refresh response: the old one stays valid and is kept. - run_
loopback_ flow - The whole local sign-in: listen on
127.0.0.1:<random port>, hand the authorization URL toon_open(open a browser, print it), wait up to five minutes for Google’s redirect, checkstate, exchange the code.