Describe the bug
pup auth login --subdomain <org> fails with invalid_grant for orgs on non-US1 regions.
pup constructs all URLs from a single site value. With --subdomain mycompany (site defaults to datadoghq.com), the authorization URL correctly becomes mycompany.datadoghq.com, but the token exchange goes to api.datadoghq.com instead of api.us3.datadoghq.com.
--site us3.datadoghq.com --subdomain mycompany doesn't help either as it constructs mycompany.us3.datadoghq.com.
To Reproduce
- Run
pup auth login --subdomain mycompany (org hosted on US3)
- Browser opens
https://mycompany.datadoghq.com/oauth2/v1/authorize?...
- Authenticate successfully via SSO
- Browser shows "Authentication Successful, Connected to Datadog (us3.datadoghq.com)"
- CLI fails with
invalid_grant
Expected behavior
Token exchange should be sent to api.us3.datadoghq.com (the actual region) instead of api.datadoghq.com.
Environment
- OS: macOS (Apple Silicon)
- Pup version: 0.65.0
- Authentication method: OAuth2
Command output
🔐 Starting OAuth2 login for site: datadoghq.com
🏢 Using SAML/SSO subdomain: mycompany.datadoghq.com
📡 Callback server started on: http://127.0.0.1:8000/oauth/callback
🔑 Requesting 85 scope(s) (use --scopes to customize)
✓ Using existing client registration
🌐 Opening browser for authentication...
⏳ Waiting for authorization...
🔄 Exchanging authorization code for tokens...
Error: token exchange failed (HTTP 400 Bad Request): {"errors": ["invalid_grant - Invalid authorization code or code verifier."]}
Additional context
Workaround: Run pup auth login --site us3.datadoghq.com, then manually replace us3.datadoghq.com with mycompany.datadoghq.com in the displayed auth URL before opening in browser. This confirms the token exchange works when sent to the correct endpoint.
Describe the bug
pup auth login --subdomain <org>fails withinvalid_grantfor orgs on non-US1 regions.pup constructs all URLs from a single
sitevalue. With--subdomain mycompany(site defaults todatadoghq.com), the authorization URL correctly becomesmycompany.datadoghq.com, but the token exchange goes toapi.datadoghq.cominstead ofapi.us3.datadoghq.com.--site us3.datadoghq.com --subdomain mycompanydoesn't help either as it constructsmycompany.us3.datadoghq.com.To Reproduce
pup auth login --subdomain mycompany(org hosted on US3)https://mycompany.datadoghq.com/oauth2/v1/authorize?...invalid_grantExpected behavior
Token exchange should be sent to
api.us3.datadoghq.com(the actual region) instead ofapi.datadoghq.com.Environment
Command output
Additional context
Workaround: Run
pup auth login --site us3.datadoghq.com, then manually replaceus3.datadoghq.comwithmycompany.datadoghq.comin the displayed auth URL before opening in browser. This confirms the token exchange works when sent to the correct endpoint.