{"record":{"id":"c3e5f35e1e59f8ca","repo":"xtekky/gpt4free","slug":"no-token","errorCode":"NO_TOKEN","errorMessage":"No GitHub OAuth token available. Please login first.","messagePattern":"No GitHub OAuth token available\\. Please login first\\.","errorType":"exception","errorClass":"TokenManagerError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/github/copilotTokenProvider.py","lineNumber":49,"sourceCode":"        self._copilot_token_expires_at = 0\n\n    async def get_copilot_token(self) -> Optional[str]:\n        \"\"\"\n        Get a valid Copilot API token.\n\n        This exchanges the GitHub OAuth token for a Copilot-specific token.\n\n        Returns:\n            The Copilot API token, or None if not available.\n        \"\"\"\n        # Check if we have a valid cached token\n        if self._copilot_token and time.time() < self._copilot_token_expires_at - 60:\n            return self._copilot_token\n\n        # Get GitHub OAuth token\n        github_creds = await self.shared_manager.getValidCredentials(self.github_client)\n        if not github_creds or not github_creds.get(\"access_token\"):\n            raise TokenManagerError(\n                \"NO_TOKEN\", \"No GitHub OAuth token available. Please login first.\"\n            )\n\n        github_token = github_creds[\"access_token\"]\n\n        # Exchange for Copilot token\n        async with aiohttp.ClientSession() as session:\n            async with session.get(\n                self.COPILOT_TOKEN_URL,\n                headers={\n                    \"Authorization\": f\"token {github_token}\",\n                    \"Accept\": \"application/json\",\n                    \"User-Agent\": USER_AGENT,\n                    \"Editor-Version\": EDITOR_VERSION,\n                    \"Editor-Plugin-Version\": EDITOR_PLUGIN_VERSION,\n                    \"Openai-Organization\": \"github-copilot\",\n                    \"X-GitHub-Api-Version\": API_VERSION,\n                },","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/github/copilotTokenProvider.py#L31-L67","documentation":"TokenManagerError with code NO_TOKEN, raised in CopilotTokenProvider when the cached Copilot token is absent/expired and the shared manager has no stored GitHub OAuth credentials to exchange. This is the root-cause error that GithubCopilot surfaces as the 'OAuth not configured' MissingAuthError (errors 60-62).","triggerScenarios":"Calling get_valid_token()/getCopilotToken() when the credentials file is missing, empty, or has no access_token, and the in-memory Copilot token cache is cold (first call or >expiry-60s since last exchange).","commonSituations":"First use after install; credentials stored under a different user/HOME (Docker, systemd service, cron); logout or credential-file cleanup between runs.","solutions":["Run 'g4f auth github-copilot' to store GitHub OAuth credentials","Verify the credential file path resolves to the same location in the process that reads it (check HOME and XDG vars in services/containers)","If tokens must be injected externally, write a valid credentials file with an access_token matching the expected schema"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from g4f.Provider.github.sharedTokenManager import TokenManagerError\n\ntry:\n    token = await provider.get_valid_token()\nexcept TokenManagerError as e:\n    if e.code == 'NO_TOKEN':\n        # trigger device-code login flow or switch provider\n        ...","preventionTips":["Branch on TokenManagerError.code rather than parsing message strings","Run login during provisioning so NO_TOKEN never occurs at request time","Verify credential file presence in container health checks"],"tags":["authentication","token-manager","oauth","github-copilot"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}