{"record":{"id":"aa81ae78afd1eb69","repo":"xtekky/gpt4free","slug":"device-authorization-error-resp-json-get-error","errorCode":null,"errorMessage":"Device authorization error: {resp_json.get('error')} - {resp_json.get('error_description')}","messagePattern":"Device authorization error: (.+?) - (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"g4f/Provider/github/githubOAuth2.py","lineNumber":110,"sourceCode":"\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:\n            dict with access_token, token_type, scope or status=pending\n        \"\"\"\n        body_data = {\n            \"grant_type\": \"urn:ietf:params:oauth:grant-type:device_code\",\n            \"client_id\": self.client_id,","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/github/githubOAuth2.py#L92-L128","documentation":"A bare Exception raised after a 200 response from the device authorization endpoint when the payload fails the isDeviceAuthorizationSuccess check — i.e. it carries an OAuth error object instead of a device_code. The message embeds the standard OAuth error and error_description fields (e.g. authorization_pending, slow_down, expired_token are handled separately upstream; others land here).","triggerScenarios":"HTTP 200 from GITHUB_DEVICE_CODE_ENDPOINT whose body contains error/error_description, such as 'unsupported_grant_type' when the OAuth app does not allow the device flow, or malformed policy rejections.","commonSituations":"Custom OAuth app without device-flow enabled; GitHub policy changes adding new error codes the client does not special-case.","solutions":["Read the embedded error_description — it states the exact OAuth failure reason","For unsupported_grant_type / disabled device flow, switch to a client_id that enables the device authorization grant or update g4f","Retry after correcting the OAuth app configuration; transient policy errors clear with a new request"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    device_auth = await client.authorizeDevice()\nexcept Exception as e:\n    if 'Device authorization error' in str(e):\n        # inspect embedded error_description; fix OAuth app config, then retry once\n        log.warning('device auth rejected: %s', e)","preventionTips":["Verify the OAuth app supports the device authorization grant before using this flow","Surface error_description to the user — it names the exact grant problem","Update g4f when GitHub adds new device-flow error codes"],"tags":["oauth","device-flow","validation","github"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}