ApiKey No Expiration #1403

Closed
opened 2026-03-13 08:38:08 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @emersonlaurentino on GitHub (Jun 22, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Use the ApiKey plugin

Current vs. Expected behavior

expiresIn is required on creation, the solution could be to make it optional or accept the value as 0.

What version of Better Auth are you using?

1.2.10

Provide environment information

- OS: macOS Sequoia Version 15.5
- Browser: Chrome Version 137.0.7151.120 (Official Build) (arm64)

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  plugins: [apiKey({ defaultPrefix: "bk_" })]
});

Additional context

No response

Originally created by @emersonlaurentino on GitHub (Jun 22, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Use the ApiKey plugin ### Current vs. Expected behavior `expiresIn` is required on creation, the solution could be to make it optional or accept the value as 0. ### What version of Better Auth are you using? 1.2.10 ### Provide environment information ```bash - OS: macOS Sequoia Version 15.5 - Browser: Chrome Version 137.0.7151.120 (Official Build) (arm64) ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, plugins: [apiKey({ defaultPrefix: "bk_" })] }); ``` ### Additional context _No response_
GiteaMirror added the plugin label 2026-03-13 08:38:08 -05:00
Author
Owner

@ping-maxwell commented on GitHub (Jun 22, 2025):

You should be able to set expiresAt to null to not expire.

@ping-maxwell commented on GitHub (Jun 22, 2025): You should be able to set `expiresAt` to `null` to not expire.
Author
Owner

@emersonlaurentino commented on GitHub (Jun 22, 2025):

As I copied the schema by hand from the documentation, I put as not null, changed my db and it worked correctly, thank you.

@emersonlaurentino commented on GitHub (Jun 22, 2025): As I copied the schema by hand from the documentation, I put as `not null`, changed my db and it worked correctly, thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1403