[GH-ISSUE #1665] insert permissions on server side #8855

Closed
opened 2026-04-13 04:05:46 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @yeferson59 on GitHub (Mar 3, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1665

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

static async createApiKey(
headers: IncomingHttpHeaders,
data: CreateApiKeyDto,
) {
console.log(data);
const apikey = await auth.api.createApiKey({
headers: fromNodeHeaders(headers),
body: {
permissions: {
projects: ["read"],
},
},
});
return apikey;
}

Current vs. Expected behavior

I hope to create apikey with their data but this show error:

APIError: The property you're trying to set can only be set from the server auth instance only.

but I'm in the server

What version of Better Auth are you using?

1.2.2

Provide environment information

- Os MacOs sequoia 15.3.1
- Thunder client

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

Backend

Auth config (if applicable)

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

Additional context

No response

Originally created by @yeferson59 on GitHub (Mar 3, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1665 ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce static async createApiKey( headers: IncomingHttpHeaders, data: CreateApiKeyDto, ) { console.log(data); const apikey = await auth.api.createApiKey({ headers: fromNodeHeaders(headers), body: { permissions: { projects: ["read"], }, }, }); return apikey; } ### Current vs. Expected behavior I hope to create apikey with their data but this show error: APIError: The property you&#39;re trying to set can only be set from the server auth instance only.</pre> but I'm in the server ### What version of Better Auth are you using? 1.2.2 ### Provide environment information ```bash - Os MacOs sequoia 15.3.1 - Thunder client ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import { apiKey } from "better-auth/plugins"; export const auth = betterAuth({ emailAndPassword: { enabled: true }, plugins: [apiKey()] }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 04:05:46 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 12, 2025):

Hi, @yeferson59. I'm Dosu, and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You are experiencing an error when generating an API key using the Better Auth library on the server side.
  • The error message indicates a property should only be set from the server auth instance.
  • You are using version 1.2.2 of Better Auth on MacOS Sequoia 15.3.1 with Thunder client.
  • This issue is affecting your backend operations.
  • There have been no comments or developments on this issue yet.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of the better-auth repository. If it is, you can keep the discussion open by commenting here.
  • If there is no further activity, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:2967419349 --> @dosubot[bot] commented on GitHub (Jun 12, 2025): Hi, @yeferson59. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - You are experiencing an error when generating an API key using the Better Auth library on the server side. - The error message indicates a property should only be set from the server auth instance. - You are using version 1.2.2 of Better Auth on MacOS Sequoia 15.3.1 with Thunder client. - This issue is affecting your backend operations. - There have been no comments or developments on this issue yet. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of the better-auth repository. If it is, you can keep the discussion open by commenting here. - If there is no further activity, this issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Author
Owner

@AhmedBaset commented on GitHub (Nov 12, 2025):

Hey @yeferson59, I see you closed this as completed. Have you found a solution? I'm running into the same issue

<!-- gh-comment-id:3524059082 --> @AhmedBaset commented on GitHub (Nov 12, 2025): Hey @yeferson59, I see you closed this as completed. Have you found a solution? I'm running into the same issue
Author
Owner

@yeferson59 commented on GitHub (Nov 12, 2025):

Hey @yeferson59, I see you closed this as completed. Have you found a solution? I'm running into the same issue

That issue is for no give userId as parameter on create api key lol

<!-- gh-comment-id:3524187129 --> @yeferson59 commented on GitHub (Nov 12, 2025): > Hey @yeferson59, I see you closed this as completed. Have you found a solution? I'm running into the same issue That issue is for no give userId as parameter on create api key lol
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8855