## duckdb.set_token_secret()


Register an access token as a DuckDB Azure secret.


Usage

``` python
duckdb.set_token_secret(
    conn,
    token,
    account=None,
)
```


As `quak::az_set_token_secret()`: `CREATE OR REPLACE SECRET` with `PROVIDER access_token`, named `dazapiz_default`, or `dazapiz_<account>` with `account`. The token expires and is not refreshed: see [set_credential_secret()](duckdb.set_credential_secret.md#dazapiz.duckdb.set_credential_secret).


## Parameters


`conn: duckdb.DuckDBPyConnection`  
The DuckDB connection; the `azure` extension is installed and loaded if it is not yet.

`token: str`  
A storage access token (a bearer token for [STORAGE_SCOPE](duckdb.STORAGE_SCOPE.md#dazapiz.duckdb.STORAGE_SCOPE)).

`account: str | None = None`  
Scope the secret to this storage account's hosts: a bare name (`myaccount`) or a fully qualified host. Default: unscoped.


## Raises


`TypeError`  
`token` or `account` is not a string.

`ValueError`  
`token` or `account` is empty or holds a NUL character.

`duckdb.Error`  
DuckDB refused the statement; the message never carries the token.


## Notes

An account-scoped secret applies to Parquet, CSV and JSON reads; Delta tables never match one, so register an unscoped secret for them.


## Examples

``` python
import duckdb
from dazapiz.duckdb import set_token_secret

conn = duckdb.connect()
set_token_secret(conn, token, account="myaccount")
```
