Pick a redirect URI
The host and path must match what you registered.
localhost and 127.0.0.1 are different hosts, so use the same one in both places.
Sign in from a CLI
This example starts a temporary local server, prints the sign-in link, waits for the callback, and exchanges the code. It ignores any request that doesn’t carry itsstate, so only the real callback ends the wait. It gives up after five minutes, which is how long the consent screen stays valid, and it closes each connection after replying so the process can exit as soon as sign-in finishes. It needs Node.js 20 or later and no dependencies.
login.mjs
client_secret. Everything else matches a server app, so refreshing, errors, and disconnecting work as described for web products, without the secret.
Store tokens on the device
Keep the refresh token in the operating system’s credential store: Keychain on macOS and iOS, Credential Manager on Windows, encrypted storage on Android, or the Secret Service on Linux. Avoid plain files, shell history, and logs.Several devices
A person can sign in on more than one device. Every device gets its own tokens, and devices that asked for the same scopes share one connection, so:- Signing in on a new device does not sign out the others.
- Disconnecting, from your app or from the user’s Connected apps page, signs out every device.
- Each device must keep its own refresh token up to date. Reusing a refresh token more than a minute after it was replaced ends the connection for every device.