# How to setup OpenAI style service accounts using Auth0

**URL:** <https://community.auth0.com/t/how-to-setup-openai-style-service-accounts-using-auth0/149898>\
**Category:** Get Help\
**Tags:** user-password-management, user-management\
**Created:** [October 15, 2024, 11:57am UTC](https://community.auth0.com/t/how-to-setup-openai-style-service-accounts-using-auth0/149898 "2024-10-15T11:57:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robert\_moyai](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/robert_moyai/32/59988_2.png) [@robert\_moyai](https://community.auth0.com/u/robert_moyai)\
**Post date:** [October 15, 2024, 11:57am UTC](https://community.auth0.com/t/how-to-setup-openai-style-service-accounts-using-auth0/149898/1 "2024-10-15T11:57:30Z")

</div>

Hello 👋

I recently started using Auth0 for the securing my fastapi application. I currently have users that can sign in and use the token they receive back to access protected routes. All good but I am looking to improve my security posture and make it more user friendly inspired with OpenAI use of service accounts.

I would like to add users to organisations and limit what a user can do using the organisation she is a member off. For example when requesting a list I would like to ensure that the query response uses the organisation settings to limit what is returned to what its in the user her organisation.

Second OpenAI has service account tokens that can be requested once you are signed into the application. The tokens are shown only once and are throwaway. They dont expire which makes it convenient to use it in m2m communication.

What features in Auth0 would help me achieve these setups? Any advice or ideas are much appreciated.

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [October 15, 2024, 1:06pm UTC](https://community.auth0.com/t/how-to-setup-openai-style-service-accounts-using-auth0/149898/3 "2024-10-15T13:06:13Z")

</div>

Hi @robert_moyai

Welcome to the Auth0 Community!

Thank you for posting your question.

> I would like to add users to organisations and limit what a user can do using the organisation she is a member off. For example when requesting a list I would like to ensure that the query response uses the organisation settings to limit what is returned to what its in the user her organisation.

You can achieve mentioned results with the usage or organization with role-based access control. Here are a few link that can help you:

- [Role-Based Access Control](https://auth0.com/docs/manage-users/access-control/rbac)
- [What is Role-Based Access Control (RBAC)? - Auth0](https://auth0.com/intro-to-iam/what-is-role-based-access-control-rbac)
- [Enable Role-Based Access Control for APIs](https://auth0.com/docs/get-started/apis/enable-role-based-access-control-for-apis)
- [Adding RBAC Permissions to Access Tokens](https://community.auth0.com/t/adding-rbac-permissions-to-access-tokens/147551)
- [How to Create a Paywall or Restrict Usage to an App for Subscribed Users Only](https://community.auth0.com/t/how-to-create-a-paywall-or-restrict-usage-to-an-app-for-subscribed-users-only/118989)

> Second OpenAI has service account tokens that can be requested once you are signed into the application. The tokens are shown only once and are throwaway. They dont expire which makes it convenient to use it in m2m communication.

The maximum you can set an access token is 30 days → [Update Access Token Lifetime](https://auth0.com/docs/secure/tokens/access-tokens/update-access-token-lifetime)

Thanks  
Dawid

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 29, 2024, 1:07pm UTC](https://community.auth0.com/t/how-to-setup-openai-style-service-accounts-using-auth0/149898/4 "2024-10-29T13:07:04Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
