# How to use a current users credentials in a plugin for read / write

**URL:** <https://forum.builder.io/t/how-to-use-a-current-users-credentials-in-a-plugin-for-read-write/15470>\
**Category:** Technical Questions\
**Created:** [July 27, 2025, 5:14pm UTC](https://forum.builder.io/t/how-to-use-a-current-users-credentials-in-a-plugin-for-read-write/15470 "2025-07-27T17:14:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhs129](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jhs129](https://forum.builder.io/u/jhs129)\
**Post date:** [July 27, 2025, 5:14pm UTC](https://forum.builder.io/t/how-to-use-a-current-users-credentials-in-a-plugin-for-read-write/15470/1 "2025-07-27T17:14:32Z")

</div>

I am developing a custom plugin that needs to read and write to [builder.io](http://builder.io). Currently I am configuring settings in the plugin to provide access to the respective API keys but I believe this causes a security risk as anyone who has access to the plugin could do whatever the keys allow. Is there a better way to access / leverage the current users permissions in order to read / write to [builder.io](http://builder.io) rather than:

const apiKey = appState.user.organization.value.settings.publicKey || “”;  
if (apiKey) {  
builder.init(apiKey);  
builder.apiVersion = “v3”;  
}

This is an example for reading from [builder.io](http://builder.io) but i also have cases where i am having the plugin use the admin graphql api to write content as well. So curios if there is a better way to do this.

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [July 28, 2025, 11:22am UTC](https://forum.builder.io/t/how-to-use-a-current-users-credentials-in-a-plugin-for-read-write/15470/2 "2025-07-28T11:22:26Z")

</div>

Hello @jhs129,

You’re correct that exposing API keys (especially those with write access) within a plugin poses a significant security risk. Any user with access to the plugin could potentially misuse those credentials to modify or access content in unintended ways.

To clarify:

- **Public API Keys** are intended for client-side, read-only access to published content. These are safe to expose and can be used in plugin settings when limited to fetching data.
- **Private API Keys** , however, are required for write operations (such as using the Admin GraphQL API or updating content). These keys provide elevated privileges and must be kept secure — they should only be used in trusted, server-side environments and never exposed to the browser or plugin configuration accessible to users.

* * *

For scenarios where your plugin needs to read and write data:

1. **Client-side (Read-only):**  
Continue using public API keys via the plugin for safe, read-only access.
2. **Server-side (Read/Write):**  
For write operations or Admin GraphQL API usage, we strongly recommend routing these actions through a secure server-side service that:
  - Stores and uses the private API key securely (e.g., via environment variables)
  - Exposes only the required endpoints to your plugin
  - Validates and sanitizes input from the plugin to control access

This architecture keeps your private key protected while still enabling the functionality you need.

> **[Using the Builder API Key](https://www.builder.io/c/docs/using-your-api-key#managing-private-keys)**
>
> Builder is an AI-Powered Visual Development Platform that helps teams generate, iterate, and optimize web and mobile experiences in seconds instead of sprints.

Best regards,

---

<div class="post-metadata">

**Author:** ![jhs129](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jhs129](https://forum.builder.io/u/jhs129)\
**Post date:** [August 2, 2025, 4:32pm UTC](https://forum.builder.io/t/how-to-use-a-current-users-credentials-in-a-plugin-for-read-write/15470/3 "2025-08-02T16:32:31Z")

</div>

@manish-sharma I understand the security issues and hence why i wanted to try and leverage the permissions a user has been granted. for example, if a user is an admin in a space i want to enable the plugin for them otherwise restrict it. So is there a way to query the app state something like appState.user.organization.currentSpace.hasRole(“admin”)?

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [August 4, 2025, 11:42am UTC](https://forum.builder.io/t/how-to-use-a-current-users-credentials-in-a-plugin-for-read-write/15470/4 "2025-08-04T11:42:43Z")

</div>

Hello @jhs129

Just checking in—would using `appState.user.data` be helpful in your case? This should return the details of the currently logged-in user.

 ![Screenshot 2025-08-04 at 5.12.08 PM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/0/0c439aa405d8745ffd2e20f0def913a42bd2b49e.png)

Alternatively, you could consider using `appState.contentEditorPage.usersOnline` if you’re looking to access a list of users currently active in the editor.

Let me know if either of these approaches works for your use case, or if you’d like help exploring another option.

Best regards,
