{"record":{"id":"18195fdc3d04e8cb","repo":"xtekky/gpt4free","slug":"e-ask-for-help-in-the-cls-login-url-discord-s","errorCode":null,"errorMessage":"{e}. Ask for help in the {cls.login_url} Discord server.","messagePattern":"(.+?)\\. Ask for help in the (.+?) Discord server\\.","errorType":"exception","errorClass":"MissingAuthError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/Azure.py","lineNumber":155,"sourceCode":"            for key, value in cls.model_extra_body[model].items():\n                kwargs.setdefault(key, value)\n            stream = False\n        if cls.failed.get(model + api_key, 0) >= 3:\n            raise MissingAuthError(f\"API key has failed too many times.\")\n        try:\n            async for chunk in super().create_async_generator(\n                model=model,\n                messages=messages,\n                stream=stream,\n                media=media,\n                api_key=api_key,\n                api_endpoint=api_endpoint,\n                **kwargs,\n            ):\n                yield chunk\n        except MissingAuthError as e:\n            cls.failed[model + api_key] = cls.failed.get(model + api_key, 0) + 1\n            raise MissingAuthError(\n                f\"{e}. Ask for help in the {cls.login_url} Discord server.\"\n            ) from e\n","sourceCodeStart":137,"sourceCodeEnd":158,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Azure.py#L137-L158","documentation":"Thrown by the Azure provider (g4f/Provider/needs_auth/Azure.py) when the underlying Azure OpenAI request fails with MissingAuthError, i.e. the Azure AD / OAuth credentials the provider cached are absent, expired, or rejected. The provider counts the failure per model+api_key in cls.failed and re-raises a new MissingAuthError with instructions to get help in the provider's Discord server (cls.login_url). It is purely an authentication/credentials problem, not a network or model problem.","triggerScenarios":"Calling Azure.create_async_generator with an api_key that Azure rejects, with an expired cached AAD token, or with no api_key at all when the provider requires one. Each failure increments cls.failed[model + api_key]; the raise happens in the except MissingAuthError handler that wraps super().create_async_generator.","commonSituations":"Azure AD token expiring mid-session; wrong or rotated api_key for the Azure endpoint; using a custom api_endpoint whose deployment does not accept the supplied key; running g4f after Azure credential refresh changed the token.","solutions":["Supply a fresh, valid api_key for the Azure deployment when creating the generator.","Verify the api_endpoint points at the correct deployment and that the key matches that endpoint's resource.","Clear/refresh cached credentials so the provider re-authenticates from scratch instead of reusing the rejected token.","If the key should be valid, ask in the Discord server referenced by the provider's login_url, since the message suggests the credentials come from a shared/managed source."],"exampleFix":"# before\nasync for chunk in Azure.create_async_generator(model=\"gpt-4\", messages=msgs, api_key=\"stale-key\"):\n    print(chunk)\n\n# after\nasync for chunk in Azure.create_async_generator(model=\"gpt-4\", messages=msgs, api_key=valid_azure_key):\n    print(chunk)","handlingStrategy":"try-catch","validationCode":"from g4f.errors import MissingAuthError\n\nasync def safe_azure(model, messages, api_key):\n    try:\n        return [c async for c in Azure.create_async_generator(model=model, messages=messages, api_key=api_key)]\n    except MissingAuthError as e:\n        print(f\"Azure auth failed: {e}; rotating credentials\")\n        return None","typeGuard":"def is_missing_auth_error(exc: BaseException) -> bool:\n    return isinstance(exc, MissingAuthError)","tryCatchPattern":"try:\n    async for chunk in Azure.create_async_generator(...):\n        process(chunk)\nexcept MissingAuthError as e:\n    # rotate/refresh the api_key, then retry or switch provider\n    rotate_credentials_and_retry(e)","preventionTips":["Store the Azure api_key in configuration that can be rotated, not hardcoded.","Log Azure.create_async_generator failures with the model name so you know which credential is bad.","Watch the provider's cls.failed counter pattern: repeated failures mean the credential, not the request, is the problem."],"tags":["authentication","azure","provider","credentials"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}