feat: log in through OAuth 2.0 device code by default - #1402
Draft
vladfrangu wants to merge 1 commit into
Draft
Conversation
The oauth2 method is the new default for apify login: device code first, then authorization code with PKCE on a loopback server, then the legacy Console hand-off. Access tokens are refreshed transparently before they expire; the refresh token lives in the OS keyring next to the token.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
apify loginnow defaults to OAuth 2.0 against the Console authorization server instead of the bespoke Console hand-off. No new dependencies; nativefetchandnode:cryptoonly.Flow (
--method oauth2, the new default;consoleandmanualunchanged,--tokenstill short-circuits)interval.Login cancelled.APIFY_CLI_OAUTH_ISSUER_URL(defaulthttps://console-backend.apify.com). The client ID is the URL of a client metadata document,APIFY_CLI_OAUTH_CLIENT_ID(defaulthttps://apify.com/.well-known/oauth-clients/apify-cli.json, served by apify/apify-web#6599).Sessions
resolveTokenandgetLocalUserInfonow go throughgetAccessToken, which refreshes when under 60 s remain or when the refresh token has under 30 min left. At most one refresh per process; a best-effort lock file plus aninvalid_grantre-read handle concurrent CLIs, since the server rotates refresh tokens.oauth-refresh-token(inline inauth.jsonon the file backend); non-secret metadata inauth.json.oauth. Plain-token logins clear it. Logout removes it.apify runrequests a token with at least 45 min left and warns only if it could not get one.apify auth tokennotes the expiry on stderr.Not in this PR
APIFY_CLI_OAUTH_CLIENT_IDto a hosted copy of the document (CI needs this too).