+++
title = "Async Authentication"
template = "demo.html"
+++
This example shows how to implement an an async auth token flow for htmx.
The technique we will use here will take advantage of the fact that you can delay requests
using the [`htmx:confirm`](@/events.md#htmx:confirm) event.
We first have a button that should not issue a request until an auth token has been retrieved:
```html
```
Next we will add some scripting to work with an `auth` promise (returned by a library):
```html
```
Here we use a global variable, but you could use `localStorage` or whatever preferred mechanism
you want to communicate the authentication token to the `htmx:configRequest` event.
With this code in place, htmx will not issue requests until the `auth` promise has been resolved.