Repository navigation
feat: log in through OAuth 2.0 device code by default - #1402
Draft
vladfrangu wants to merge 1 commit into
Draft
vladfrangu wants to merge 1 commit into
vladfrangu wants to merge 1 commit into
Conversation
vladfrangu
force-pushed
the
feat/oauth-device-code-login
branch
from
September 30, 2026 13:41
c1552cc to
0bb110b
Compare
Contributor
|
Sorry for I am really late with this. I tested it locally (rebased on master + some small changes). I was able to connect device flow with multi account (master) and login multiple accounts. $ apify auth list
┌──────────────────────────────────────────────────────────────────────────────────────────────┐
│ Name User ID Type Last login Storage │
├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ motivated_container2 AvSU*****f52Zh Personal 2026-10-09 at 11:49:25 auth.json │
├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ richardsolar eCJxAGa*****Vvmjx Personal 2026-10-09 at 12:00:35 auth.json │
├──────────────────────────────────────────────────────────────────────────────────────────────┤
│ balrog (active) qTyaZT****bef6iQ Organization 2026-10-09 at 12:00:55 auth.json │
└──────────────────────────────────────────────────────────────────────────────────────────────┘Good job with this, I do not see any problem right now, just one thing, we are missing some token invalidation step in logout for refresh token (other wise it is still valid up to 60d), but maybe you deliberately drop it with @valekjo Do you have time to rebase this on master @vladfrangu ? If not maybe @apify/builders can take it over at this point? again GJ 🚀 |
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.
vladfrangu
force-pushed
the
feat/oauth-device-code-login
branch
from
October 9, 2026 15:20
0bb110b to
9af3f08
Compare
This branch has not been deployed
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 since apify/apify-web#6599).Sessions, per stored account
resolveAuth(both the active and the--profilebranch) andgetLocalUserInfogo throughgetAccessToken(userId), which refreshes when under 60 s remain or when the refresh token has under 30 min left. One refresh attempt per process and account; a best-effort lock file plus aninvalid_grantre-read handle concurrent CLIs, since the server rotates refresh tokens.authMethod: 'oauth2',expiresAt,hasRefreshToken, plus anoauthblock with issuer, client ID, token endpoint and refresh-token expiry. The refresh token is a third per-user secret kind,refresh-token, so it lives in the keyring servicecom.apify.cli.refresh-token(inline on the profile on the file backend) and follows the token on a keyring fallback, a--profilelogout andlogout --all.loginWithTokenstays the only credential writer. It drops any OAuth session of that account; an OAuth login validates the token through it and saves the session right after.apify runrequests a token with at least 45 min left and warns only if it could not get one. A session that cannot be refreshed degrades to a warning and the Actor runs without API access.apify auth tokennotes the expiry on stderr.Not in this PR
apify mcp installembeds the resolved token in the client config; with an OAuth login that token dies after an hour, so it should warn or ask for--token.apify auth listdoes not yet show how an account logged in or when its session expires.