# Generate User Token for Bubble Data API

**URL:** <https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620>\
**Category:** APIs\
**Created:** [September 5, 2023, 4:01pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620 "2023-09-05T16:01:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tillmann.durth](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@tillmann.durth](https://forum.bubble.io/u/tillmann.durth)\
**Post date:** [September 5, 2023, 4:01pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/1 "2023-09-05T16:01:56Z")

</div>

We want to import/export some data (e.g. books and orders) from Bubble to a 3rd party app. We are using the [Bubble Data API for](https://manual.bubble.io/core-resources/api/the-bubble-api/the-data-api/authentication) this. We have two options for authentication here as far as I know. The first one is the Admin Access Token, the second one a User Access Token. We would prefer the User Access Token, due to privacy and security. As fas as I see it the only option to generate this is, to use the Username and Password. We dont want the user to put in the Password though every 12 months and we dont want to store the password in plain text as well. Is there a other option to generate these tokens and handle the Authentication alone?

---

<div class="post-metadata">

**Author:** ![treb.gatte](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/treb.gatte/32/127901_2.png) [@treb.gatte](https://forum.bubble.io/u/treb.gatte)\
**Post date:** [September 6, 2023, 5:19am UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/2 "2023-09-06T05:19:09Z")

</div>

Funny you should ask as I’m researching the same thing. I was looking at this article: [As a User - Bubble Docs](https://manual.bubble.io/help-guides/integrations/api/the-bubble-api/authentication/as-a-user)

The issue I have is we don’t use email/password but rather OAuth with Microsoft/Google. I’m not sure how to implement this.

---

<div class="post-metadata">

**Author:** ![tylerboodman](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tylerboodman/32/242142_2.png) [@tylerboodman](https://forum.bubble.io/u/tylerboodman)\
**Post date:** [September 6, 2023, 6:03am UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/3 "2023-09-06T06:03:44Z")

</div>

Have an api\_key field (text), and key\_expiration\_date (date) on the User datatype. When they login, have it check if the expiration date is empty or older than the current date/time, if so run the API call to generate a new key using the email and password input boxes, then store the result.

For @treb.gatte , no clue 🤣

---

<div class="post-metadata">

**Author:** ![tillmann.durth](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@tillmann.durth](https://forum.bubble.io/u/tillmann.durth)\
**Post date:** [September 7, 2023, 12:21pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/4 "2023-09-07T12:21:09Z")

</div>

Thanks for the great tips @tylerboodman . As far as I can see that, this makes it still necessary though for the user to re-enter his credentials every 12 months. Is that correct?

---

<div class="post-metadata">

**Author:** ![tillmann.durth](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@tillmann.durth](https://forum.bubble.io/u/tillmann.durth)\
**Post date:** [September 7, 2023, 12:24pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/5 "2023-09-07T12:24:34Z")

</div>

I know what you mean. As far as I understood the Bubble docs you can only do this with the bubble native sign in process. We are using Google OAuth as well. If anybody has a solution for this, I would be really glad, if he could share it.

---

<div class="post-metadata">

**Author:** ![tylerboodman](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tylerboodman/32/242142_2.png) [@tylerboodman](https://forum.bubble.io/u/tylerboodman)\
**Post date:** [September 7, 2023, 1:54pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/6 "2023-09-07T13:54:18Z")

</div>

Yea, I figured they would be signing in every day or something and you can keep the token fresh. But if they are also signing on once a year then correct.

Maybe it’s good they at least sign in. yearly??

---

<div class="post-metadata">

**Author:** ![federico.tomasi](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@federico.tomasi](https://forum.bubble.io/u/federico.tomasi)\
**Post date:** [September 24, 2024, 3:24pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/7 "2024-09-24T15:24:46Z")

</div>

How do you generate the user api key as a consequence of the log in? I mean, I was looking for a specific action that made that or some checkbox (as for example when you use the send verification email action and take advantage of just generating the token) but I couldn’t find it anywhere

---

<div class="post-metadata">

**Author:** ![tylerboodman](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tylerboodman/32/242142_2.png) [@tylerboodman](https://forum.bubble.io/u/tylerboodman)\
**Post date:** [September 24, 2024, 4:18pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/8 "2024-09-24T16:18:21Z")

</div>

You do the “Log the user in” action and any subsequent actions can reference the Result of the login step (the API key)

---

<div class="post-metadata">

**Author:** ![federico.tomasi](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@federico.tomasi](https://forum.bubble.io/u/federico.tomasi)\
**Post date:** [September 24, 2024, 6:10pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/9 "2024-09-24T18:10:42Z")

</div>

Thank you. I guessed it but I can’t actually get the “result of step1” (the login action) in my following action (I use the “make changes to current user” one as I have created the api\_key field in the user datatype as you suggested, but I have checked with the “make changes to a thing” as well)…  
I also tried to check, as a first action, the “sign the user up”, but also with this I can’t see any result of this step in the following ones…sure I am doing something wrong but I can’t figure out what…

---

<div class="post-metadata">

**Author:** ![tylerboodman](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tylerboodman/32/242142_2.png) [@tylerboodman](https://forum.bubble.io/u/tylerboodman)\
**Post date:** [September 24, 2024, 6:19pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/10 "2024-09-24T18:19:49Z")

</div>

It says it has to happen in a backend API Workflow, but even so I just tried it and I’m not seeing the result either…

---

<div class="post-metadata">

**Author:** ![federico.tomasi](https://avatars.discourse-cdn.com/v4/letter/f/ed8c4c/32.png) [@federico.tomasi](https://forum.bubble.io/u/federico.tomasi)\
**Post date:** [September 24, 2024, 7:25pm UTC](https://forum.bubble.io/t/generate-user-token-for-bubble-data-api/281620/11 "2024-09-24T19:25:20Z")

</div>

Thank you for confirming…  
so I think the correct (and only) way is that exposed in this post:

> [@How to generate an API Key for users to use it when they call my endpoints?](https://forum.bubble.io/t/how-to-generate-an-api-key-for-users-to-use-it-when-they-call-my-endpoints/323867/3):
>
> OK, I made this API action and found that its response includes a token like this bus|1716577514947x598705444092944500|1716608603286x447372536663480200. Then I used this token as a Bearer API Key for another backend workflow and it worked successfully. But now I need some clarification about how this should be organized because as I can understand, this needs the following: When the user creates a new account in my app, I have to use an API action that includes the sign the user up action, s…
