Skip to main content

Auth Code with PKCE

Browser login is the default when --device-code and --client-credentials are not supplied.

teams auth login

The default redirect URI is:

http://localhost/callback

The CLI listens on a free loopback port that the OS picks at each login (on both 127.0.0.1 and ::1) and sends that port in the URI. The identity platform ignores the port of a localhost redirect URI, so the registration needs none, and a busy port never blocks login.

A bring-your-own app registered with another loopback URI passes it with --redirect-uri (or TEAMS_CLI_REDIRECT_URI, or the profile's redirect_uri):

teams auth login --client-id <client-id> --tenant-id <tenant-id> --redirect-uri http://localhost

The URI must be http on localhost or a loopback IP literal. A URI with a port fixes the port, for example for a firewall rule. After a successful login, the flag value is saved to the profile with the client and tenant IDs.

The login waits for the callback on the URI's path. If you decline consent or the tenant refuses the sign-in, it fails at once with the identity platform's error and error_description (exit code 3). With no callback at all, it gives up after 10 minutes.

If the browser cannot reach the shell host, use device code.