{"record":{"id":"2f0490664cc89b03","repo":"Significant-Gravitas/AutoGPT","slug":"credential-has-no-access-token-reconnect-the-acco","errorCode":null,"errorMessage":"Credential has no access token; reconnect the account","messagePattern":"Credential has no access token; reconnect the account","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/integrations/router.py","lineNumber":531,"sourceCode":"            status_code=status.HTTP_404_NOT_FOUND, detail=\"Credentials not found\"\n        )\n\n    credential = await creds_manager.get(user_id, cred_id)\n    if not credential:\n        raise HTTPException(\n            status_code=status.HTTP_404_NOT_FOUND, detail=\"Credentials not found\"\n        )\n    if not provider_matches(credential.provider, provider):\n        raise HTTPException(\n            status_code=status.HTTP_404_NOT_FOUND, detail=\"Credentials not found\"\n        )\n    if not isinstance(credential, OAuth2Credentials):\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Picker tokens are only available for OAuth2 credentials\",\n        )\n    if not credential.access_token:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Credential has no access token; reconnect the account\",\n        )\n\n    # Gate on provider+scope: only credentials that actually grant access to\n    # a provider-hosted picker flow may mint a token through this endpoint.\n    # Prevents using this path to extract bearer tokens for unrelated OAuth\n    # integrations (e.g. GitHub) that happen to be stored under the same user.\n    allowed_scopes = _PICKER_TOKEN_ALLOWED_SCOPES.get(provider)\n    if not allowed_scopes:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=(f\"Picker tokens are not available for provider '{provider.value}'\"),\n        )\n    cred_scopes = set(credential.scopes or [])\n    if cred_scopes.isdisjoint(allowed_scopes):\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/integrations/router.py#L513-L549","documentation":"The picker-token endpoint returns 400 'Credential has no access token; reconnect the account' when the OAuth2 credential exists but its access_token is empty. This can happen for provider_runtime-refresh credentials or corrupted/stripped records where no usable bearer token is stored.","triggerScenarios":"POST picker-token against an OAuth2 credential whose access_token is None/empty (e.g. a provider-runtime credential that only materializes tokens at call time, or a record written without a token).","commonSituations":"Credential created through a non-standard path that skipped storing the access token; token was dropped during a migration or manual DB edit; provider_runtime strategy credentials (which the create endpoint now blocks) already in the store.","solutions":["Reconnect the account: run the provider's OAuth login flow again so a fresh access token is stored","If it recurs, inspect the stored credential row (dev only) to see whether access_token is null and why","Delete the broken credential and re-create it via the normal connect flow"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if resp.status_code == 400 and 'reconnect' in resp.json()['detail']:\n    await start_oauth_login(provider)  # refresh credential, then retry once\nelse:\n    resp.raise_for_status()","preventionTips":["After any credential migration, verify OAuth2 rows still carry an access token"],"tags":["credentials","picker","oauth2","access-token","http-400"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}