{"record":{"id":"31e9452d31938cc3","repo":"xtekky/gpt4free","slug":"device-authorization-failed-resp-status-resp-j","errorCode":null,"errorMessage":"Device authorization failed {resp.status}: {resp_json}","messagePattern":"Device authorization failed (.+?): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"g4f/Provider/github/githubOAuth2.py","lineNumber":105,"sourceCode":"        \"\"\"\n        body_data = {\n            \"client_id\": self.client_id,\n            \"scope\": options.get(\"scope\", GITHUB_COPILOT_SCOPE),\n        }\n\n        async with aiohttp.ClientSession() as session:\n            async with session.post(\n                GITHUB_DEVICE_CODE_ENDPOINT,\n                headers={\n                    \"Content-Type\": \"application/x-www-form-urlencoded\",\n                    \"Accept\": \"application/json\",\n                },\n                data=object_to_urlencoded(body_data),\n            ) as resp:\n                resp_json = await resp.json()\n\n                if resp.status != 200:\n                    raise Exception(\n                        f\"Device authorization failed {resp.status}: {resp_json}\"\n                    )\n\n                if not isDeviceAuthorizationSuccess(resp_json):\n                    raise Exception(\n                        f\"Device authorization error: {resp_json.get('error')} - {resp_json.get('error_description')}\"\n                    )\n\n                return resp_json\n\n    async def pollDeviceToken(self, options: dict) -> Union[Dict, ErrorDataDict]:\n        \"\"\"\n        Poll for device token from GitHub.\n\n        Args:\n            options: dict with device_code\n\n        Returns:","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/github/githubOAuth2.py#L87-L123","documentation":"A bare Exception raised by GithubOAuth2Client device authorization when POSTing to the GitHub device-code endpoint (GITHUB_DEVICE_CODE_ENDPOINT) returns a non-200 status. The status and parsed JSON body are included, so common causes (401 bad client_id, 429 rate limit, 5xx) are visible in the message. This is the first step of the device flow: obtaining device_code and user_code.","triggerScenarios":"Starting device-code login when the OAuth client_id is invalid/revoked (401), device-flow rate limits are hit (429), or GitHub is erroring (5xx).","commonSituations":"A fork/modified g4f with a wrong client_id; too many login attempts in a short window; GitHub OAuth outage.","solutions":["Read the embedded resp_json error field — 'incorrect_client_credentials' means the bundled client_id is wrong; update g4f","Wait and retry for 429/5xx (device-flow rate limits reset within minutes)","If using a custom OAuth app, verify its client_id and that the device flow is enabled for it"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    device_auth = await client.authorizeDevice()\nexcept Exception as e:\n    if ' 429 ' in str(e) or ' 5' in str(e):\n        await asyncio.sleep(30)\n        device_auth = await client.authorizeDevice()\n    raise","preventionTips":["Do not start the device flow in a tight loop — GitHub rate-limits device authorization","Keep g4f's bundled client_id intact; custom apps must enable the device grant","Check GitHub's status page during suspected outages before debugging code"],"tags":["oauth","device-flow","http-error","github"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}