fix(bearer): certain sign-in endpoints won't give bearer token v2 (#4330)

This commit is contained in:
Maxwell
2025-09-03 04:19:34 +10:00
committed by GitHub
parent b4f0c1a98a
commit 9f15d23f77
6 changed files with 140 additions and 2 deletions

View File

@@ -22,6 +22,15 @@ export const auth = betterAuth({
});
```
And in your auth client as well:
```ts title="auth-client.ts"
import { bearerClient } from "better-auth/client/plugins";
export const authClient = createAuthClient({
plugins: [bearerClient()]
});
```
## How to Use Bearer Tokens
### 1. Obtain the Bearer Token
@@ -57,7 +66,6 @@ export const authClient = createAuthClient({
});
```
You may want to clear the token based on the response status code or other conditions:
### 2. Configure the Auth Client
@@ -137,3 +145,10 @@ export async function handler(req, res) {
## Options
**requireSignature** (boolean): Require the token to be signed. Default: `false`.
**cookieName** (string): Custom cookie name for the temporary bearer token confirmation cookie. Default: `"bearer-token-confirmation"`.
(For more information, [read here](https://github.com/better-auth/better-auth/pull/4330))
<Callout type="warn">
If this value is changed, make sure to update the client plugin's `cookieName` option.
</Callout>