# oAuth & Database?

**URL:** <https://community.auth0.com/t/oauth-database/36759>\
**Category:** Get Help\
**Tags:** vuejs\
**Created:** [January 23, 2020, 11:38am UTC](https://community.auth0.com/t/oauth-database/36759 "2020-01-23T11:38:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Plainnn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/plainnn/32/18657_2.png) [@Plainnn](https://community.auth0.com/u/Plainnn)\
**Post date:** [January 23, 2020, 11:38am UTC](https://community.auth0.com/t/oauth-database/36759/1 "2020-01-23T11:38:41Z")

</div>

Hello,

I have implemented my oAuth using the guide you have for Vue. It works and I have built a profile page (horrah!) Currently it only shows the data i get back after logging in but it’s a start.

On my profile page I have a form which users can enter words to be saved to a database (I understand how to do the CRUD operations) but how do i do that? Since i need to have the words attatched to a user ID, but how do i push a userId to a database? In which part of the flow?

---

<div class="post-metadata">

**Author:** ![markd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/markd/32/38919_2.png) [@markd](https://community.auth0.com/u/markd)\
**Post date:** [January 24, 2020, 3:16pm UTC](https://community.auth0.com/t/oauth-database/36759/2 "2020-01-24T15:16:49Z")

</div>

Hello @Plainnn,

This is pretty generic advice, but I hope it helps: you are going to want to have a common and unique key between your user profiles in Auth0 and the database where you are storing the text entered by the user. You can use the Auth0 `user_id` field as a unique key, though personally I prefer to generate my own unique identifier with an Auth0 [rule](https://auth0.com/docs/rules). For example:

> <https://github.com/dmark/auth0-cli-utilities/blob/master/rules/add-uuid-to-app-metadata.js>

Whatever identifier you decide to use from Auth0, you can use a rule to include that attribute in your `idToken` and / or access token, which your app can then use to populate the database.

---

<div class="post-metadata">

**Author:** ![Plainnn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/plainnn/32/18657_2.png) [@Plainnn](https://community.auth0.com/u/Plainnn)\
**Post date:** [January 24, 2020, 5:57pm UTC](https://community.auth0.com/t/oauth-database/36759/4 "2020-01-24T17:57:18Z")

</div>

Hey that works, thanks a lot. How do i now send this UUID to my database?

---

<div class="post-metadata">

**Author:** ![markd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/markd/32/38919_2.png) [@markd](https://community.auth0.com/u/markd)\
**Post date:** [January 24, 2020, 7:43pm UTC](https://community.auth0.com/t/oauth-database/36759/5 "2020-01-24T19:43:15Z")

</div>

I’m afraid those details are a bit beyond me (I’m not a developer). WHatever development environment you are using likely has libraries for talking to your database solution. Once you’ve created the UUID and added it to your `idToken` it will be available in your app for sending to your database.

---

<div class="post-metadata">

**Author:** ![Plainnn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/plainnn/32/18657_2.png) [@Plainnn](https://community.auth0.com/u/Plainnn)\
**Post date:** [January 24, 2020, 7:59pm UTC](https://community.auth0.com/t/oauth-database/36759/6 "2020-01-24T19:59:36Z")

</div>

Sorry, I should’ve been more clear, i actually mean how do i add it to my ID token, currently i get nickname, name, picture, updated at etc…

---

<div class="post-metadata">

**Author:** ![markd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/markd/32/38919_2.png) [@markd](https://community.auth0.com/u/markd)\
**Post date:** [January 24, 2020, 9:39pm UTC](https://community.auth0.com/t/oauth-database/36759/7 "2020-01-24T21:39:58Z")

</div>

That part I can help with! Again you can use a rule, one that runs after the UUID rule, which adds profile data to the `idToken` and / or access token. Something like (this super basic code has not been tested):

```auto
function (user, context, callback) {
// Adds app_metadata.uuid to the idToken
  var namespace = "https://yourdomain.com/claims/";
  context.idToken[namespace + "uuid"] = user.app_metadata.uuid || ""; 
  callback(null, user, context);
}

```

You might want to make that smarter by checking for the presence of the UUID attribute rather than blindly assigning something.

---

<div class="post-metadata">

**Author:** ![simpleauthority](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/simpleauthority/32/18587_2.png) [@simpleauthority](https://community.auth0.com/u/simpleauthority)\
**Post date:** [January 24, 2020, 9:44pm UTC](https://community.auth0.com/t/oauth-database/36759/8 "2020-01-24T21:44:46Z")

</div>

Do also note the namespace is **required**. It has to be generally like so `http(s)://(namespace).TLD(/optional further namespacing)/(claimId)`

I say this because I was confused myself. I tried things like `pt://` (a custom scheme I use to refer to my services internally) and this did not work, and it also did not work when omitting the TLD. I ended up just using my normal production domain as the namespace and then it did work.

---

<div class="post-metadata">

**Author:** ![Plainnn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/plainnn/32/18657_2.png) [@Plainnn](https://community.auth0.com/u/Plainnn)\
**Post date:** [January 24, 2020, 9:54pm UTC](https://community.auth0.com/t/oauth-database/36759/9 "2020-01-24T21:54:31Z")

</div>

Unreal, you don’t understand how much this helps! I would like to know if it possible to find this info in the docs/guides you have. I’ve been looking forever and couldn’t work it out! Maybe i’m just too new too this ^^

---

<div class="post-metadata">

**Author:** ![markd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/markd/32/38919_2.png) [@markd](https://community.auth0.com/u/markd)\
**Post date:** [January 24, 2020, 10:04pm UTC](https://community.auth0.com/t/oauth-database/36759/10 "2020-01-24T22:04:22Z")

</div>

The Auth0 docs are extensive (~800,000 words last time I checked), and there’s a lot of great material in there, though it can be hard to find what you need. The platform is evolving rapidly so I am sure it is difficult to keep it all up to date and organized.

Be sure to check the blog because many of the Auth0 content engineer folks write super detailed posts like this:

> **[Beginner Vue.js Tutorial with User Login](https://auth0.com/blog/beginner-vuejs-tutorial-with-user-login/)**
>
> Learn how to build a Vue.js application from scratch and easily add authentication so that users can register and login.

Blog:

> **[Search](https://auth0.com/blog/search/?query=vue.js&page=1)**
>
> Company Updates & Technology Articles

---

<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:** [February 8, 2020, 10:04pm UTC](https://community.auth0.com/t/oauth-database/36759/11 "2020-02-08T22:04:23Z")

</div>

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