# 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="../../../getting-started#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="../../../getting-started#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")
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dbnl.com/v0.21.x/using-distributional/python-sdk/sdk-functions/login.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
