> For the complete documentation index, see [llms.txt](https://docs.dbnl.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dbnl.com/v0.21.x/using-distributional/python-sdk/sdk-functions/login.md).

# login

```python
dbnl.login(
    *,
    api_token: Optional[str] = None,
    namespace_id: Optional[str] = None,    
    api_url: Optional[str] = None,
    app_url: Optional[str] = None,  
) -> None
```

Setup dbnl SDK to make authenticated requests. After login is run successfully, the dbnl client will be able to issue secure and authenticated requests against hosted endpoints of the dbnl service.&#x20;

{% hint style="warning" %}
`dbnl.login` must be run before any other functions in the DBNL workflow
{% endhint %}

## Parameters

<table><thead><tr><th width="194">Arguments</th><th>Description</th></tr></thead><tbody><tr><td><code>api_token</code></td><td>The API token used to authenticate your DBNL account. You can generate your API token at <a href="https://app.dbnl.com/tokens">https://app.dbnl.com/tokens</a> (also, see <a href="/pages/4U9M4YxabIUWaj626VU5#accessing-the-distributional-ui-and-api-token">accessing DBNL token</a>). If none is provided, the<a href="https://docs.google.com/document/d/18805wEGPmHqFPeMM2jzsFaJ3nwhRHz9bpQjDyAO2vCo/edit#heading=h.lzbvgfwy7yoj"> </a><a href="/pages/4U9M4YxabIUWaj626VU5#environment-variables">environmental variable </a><code>DBNL_API_TOKEN</code> will be used by default.</td></tr><tr><td><code>namespace_id</code></td><td>Namespace ID to use for the session; available namespaces can be found with <code>get_my_namespaces()</code>.</td></tr><tr><td><code>api_url</code></td><td>The base url of the Distributional API. For SaaS users, set this variable to <code>api.dbnl.com</code>. For other users, please contact your sys admin.</td></tr><tr><td><code>app_url</code></td><td>An optional base url of the Distributional app. If this variable is not set, the app url is inferred from the <code>DBNL_API_URL</code> variable. For on-prem users, please contact your sys admin if you cannot reach the Distributional UI.</td></tr></tbody></table>

## Examples

```python
import dbnl
# when login() is called without specifying a token, 
# it will use the `DBNL_API_TOKEN` env var
dbnl.login()

# login() can be called with a specific API Token
dbnl.login(api_token="YOUR_TOKEN_AAAA_BBBB_CCCC_DDDD")
```
