Skip to content

apify create --source github hangs at "Waiting for authorization" when logged in as an organization #1370

Description

@l2ysho

Important

TL;DR — missing routePrefix causes OAuth code is always verified against user's personal Apify account, even if user is logged in organization.

Repro

  1. apify login with an organization token
  2. apify create → any template → Where will the source code live? → GitHub
  3. Open the printed link, authorize on GitHub

Result:

Info: Connect your github account to Apify: https://github.com/login/oauth/authorize?client_id=...
Info: Waiting for authorization to complete in your browser...

The browser tab does nothing visible. The CLI polls for 3 minutes, then stops with notAuthorized.

Seen on 1.9.0 (#1348), production API.

Cause

GET /v2/integrations/git reports GitHub only when the authenticated user has the GitHub App authorized. With an organization token, that is the organization user.

The Console callback page verifies the OAuth code against whichever Apify account the browser session resolves to, which depends on a routePrefix query parameter in the redirect URI. Console adds routePrefix=/organization/<id> when it is in an organization context. The CLI does not send it, so the code is always verified against the personal account.

Evidence, with an organization login, after a completed GitHub authorization:

$ apify api integrations/git
{ "data": [] }

Bugs

  1. No routePrefix in the redirect URIgetGitConnectUrl in src/lib/git-source/gitSource.ts. An organization login cannot be connected from the CLI at all.
  2. No feedback on the callback page — the page is built for Console's popup flow: it verifies, then calls window.close(). Opened as a normal tab by open(), window.close() is a no-op, so success and failure look the same, and nothing states which Apify account was connected.
  3. The poll cannot ask for the app install — the wait loop only exits on workspaces.length. An integration that appears mid-poll with zero workspaces (authorized, but the GitHub App installed nowhere) keeps polling to the timeout, instead of switching to the install URL the CLI already knows.

Proposed fix

  • Send routePrefix=%2Forganization%2F<id> in the redirect URI when auth.json has organizationOwnerUserId (the CLI already checks this in src/commands/actors/push.ts).
  • Name the target Apify account in the Waiting for authorization... line.
  • Re-evaluate the stop condition on every poll, so a 0-workspace integration opens the install URL instead of waiting out the timeout.
  • Warn when the authorization lands on a different account than the CLI token, instead of timing out silently.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

t-buildersIssues owned by the Builders team.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions