OAuth authorize redirects to instance subdomain after login, returns 404

Hello. Could you please help me with this issue:
When a user is not logged in to Pipedrive and initiates an OAuth authorization flow,
the login page redirects to the user’s instance subdomain
({company}.pipedrive.com/marketplace/oauth/authorize) instead of
https://oauth.pipedrive.com/oauth/authorize. The instance subdomain returns 404 for this
endpoint, breaking the entire OAuth flow.

When the user is already logged in, the same authorize URL works correctly — they see
the authorize screen and can complete the flow.

Steps to Reproduce

  1. Open a browser with no active Pipedrive session (incognito window)
  2. Navigate to the OAuth authorize URL:
    https://oauth.pipedrive.com/oauth/authorize?client_id={CLIENT_ID}&redirect_uri=``{REDIRECT_URI}&state={STATE}
  3. Pipedrive redirects to login page:
    <https://oauth.pipedrive.com/auth/login?return_url=https://oauth.pipedrive.com/oauth/a>uthorize?...
  4. Enter credentials and submit
  5. After login, Pipedrive redirects to:
    https://{company}.pipedrive.com/marketplace/oauth/authorizeclient_id=…&redirect_uri=…&state=…
  6. Result: 404 page

Expected Behavior

After login, redirect should go back to https://oauth.pipedrive.com/oauth/authorize (as
specified in the return_url), not to the instance subdomain.

Workaround

If the user manually navigates back to the app and initiates the OAuth flow a second
time, Pipedrive recognizes the existing session and opens
https://oauth.pipedrive.com/marketplace/oauth/authorize correctly — authorization completes
normally.

Any hints how to make it work from first attempt?