{"record":{"id":"77fef9159caccc1d","repo":"pola-rs/polars","slug":"the-provided-credential-object-credential-r-do","errorCode":null,"errorMessage":"the provided `credential` object {credential!r} does not have a `get_token()` method.","messagePattern":"the provided `credential` object (.+?) does not have a `get_token\\(\\)` method\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/cloud/credential_provider/_providers.py","lineNumber":379,"sourceCode":"        msg = \"`CredentialProviderAzure` functionality is considered unstable\"\n        issue_unstable_warning(msg)\n\n        self.account_name = _storage_account\n        self.scopes = (\n            scopes if scopes is not None else [\"https://storage.azure.com/.default\"]\n        )\n        self.tenant_id = tenant_id\n        self.credential = credential\n\n        if credential is not None:\n            # If the user passes a credential class, we just need to ensure it\n            # has a `get_token()` method.\n            if not hasattr(credential, \"get_token\"):\n                msg = (\n                    f\"the provided `credential` object {credential!r} does \"\n                    \"not have a `get_token()` method.\"\n                )\n                raise ValueError(msg)\n\n        # We don't need the module if we are permitted and able to retrieve the\n        # account key from the Azure CLI.\n        elif self._try_get_azure_storage_account_credential_if_permitted() is None:\n            self._ensure_module_availability()\n\n        if verbose():\n            eprint(\n                \"[CredentialProviderAzure]: \"\n                f\"{self.account_name = } \"\n                f\"{self.tenant_id = } \"\n                f\"{self.scopes = } \"\n            )\n\n        super().__init__()\n\n    def retrieve_credentials_impl(self) -> CredentialProviderFunctionReturn:\n        \"\"\"Fetch the credentials.\"\"\"","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/io/cloud/credential_provider/_providers.py#L361-L397","documentation":"CredentialProviderAzure accepts an optional user-supplied `credential` object (typically from azure.identity). The constructor needs exactly one thing from it - a get_token() method (py-polars/src/polars/io/cloud/credential_provider/_providers.py:373-380); any object without that attribute raises ValueError immediately, with the repr of the offending object embedded in the message.","triggerScenarios":"pl.CredentialProviderAzure(credential='AccountKey=...') (a connection string), credential={'client_id': ...} (a dict of secrets), or a BlobServiceClient instance - none expose get_token. ClientSecretCredential/DefaultAzureCredential/ManagedIdentityCredential all work.","commonSituations":"Config schemas whose 'credential' field actually holds an account key or connection string; passing the wrong azure SDK object; objects from older azure SDK versions lacking get_token.","solutions":["Pass a real azure.identity credential (ClientSecretCredential, DefaultAzureCredential, ...) - all expose get_token","If you meant an account key, pass it via storage_options (account_key) instead of `credential`","Wrap a custom token source in a small adapter class exposing get_token(*scopes)"],"exampleFix":"# before\nprovider = pl.CredentialProviderAzure(credential=\"AccountKey=...\")\n# after\nfrom azure.identity import ClientSecretCredential\nprovider = pl.CredentialProviderAzure(\n    credential=ClientSecretCredential(tenant_id, client_id, client_secret)\n)","handlingStrategy":"type-guard","validationCode":"def validate_azure_credential(credential: object) -> None:\n    if credential is not None and not (\n        hasattr(credential, \"get_token\") and callable(credential.get_token)\n    ):\n        raise TypeError(\n            \"credential must be an azure.identity object exposing get_token(); \"\n            \"pass raw keys via storage_options instead\"\n        )","typeGuard":"def is_token_credential(obj: object) -> bool:\n    return obj is None or (hasattr(obj, \"get_token\") and callable(obj.get_token))","tryCatchPattern":"try:\n    provider = pl.CredentialProviderAzure(credential=cred)\nexcept ValueError as e:\n    if \"get_token()\" in str(e):\n        raise TypeError(\"pass an azure.identity credential, not a key/connection string\") from e\n    raise","preventionTips":["Type config fields expecting azure.identity credentials; keep raw keys in storage_options","Unit-test that the configured object has a callable get_token before deployment","Do not reuse fields named 'credential' to carry connection strings or dicts"],"tags":["polars","azure","credentials","azure-identity","valueerror"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}