# What is the options(client\_id,secret) to send to make an api call, in action after post login (onExecutePostLogin)?

**URL:** <https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [February 6, 2023, 1:26pm UTC](https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794 "2023-02-06T13:26:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neos](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neos/32/34386_2.png) [@Neos](https://community.auth0.com/u/Neos)\
**Post date:** [February 6, 2023, 1:26pm UTC](https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794/1 "2023-02-06T13:26:15Z")

</div>

Hello,

I am using auth, everything seems working fine 😄 , but i am blocked in one point : it is to send user\_id of authO to my app, to store it in database.  
After reading between rules and actions, i choosed the action.

1)I followed this tutorial  
[https://community.auth0.com/t/how-do-i-make-an-axios-api-call-and-store-it-as-a-custom-claim-using-actions/84491](https://community.auth0.com/t/how-do-i-make-an-axios-api-call-and-store-it-as-a-custom-claim-using-actions/84491)

```auto
exports.onExecutePostLogin = async (event, api) => {
  const axios = require('axios');
  
  const namespace = 'https://myapp-example.com';
  const url = 'https://YOUR_URL';
  const options = {
    headers: {
      'Content-Type': 'application/json'
    }
  };
  const data = {
    username: event.user.username, 
    email: event.user.email
  };

```

I don’t see here on the options where we set the client\_id or client\_secret, domain ?

2)Then i found another post here

> [@How do I call my API from an Action?](https://community.auth0.com/t/how-do-i-call-my-api-from-an-action/69041/7):
>
> Hey @joshuarichards001, I was able to create an action that works to request a token and call an endpoint with the token, while logging the data from each request.Can you take a look and see if this will work for you? Also, can you DM me the URL (event.secrets.API\_CREATE\_USER) you are trying to call? Here is the action I created: /\*\* \* Handler that will be called during the execution of a PostUserRegistration flow. \* \* @param {Event} event - Details about the context and user that has registe…

```auto
  const tokenOptions = {
    method: 'POST',
    url: `https://${event.secrets.DOMAIN}/oauth/token`,
    headers: { 'content-type': 'application/json' },
    data: {
      grant_type: 'client_credentials',
      client_id: event.secrets.CLIENT_ID,
      client_secret: event.secrets.CLIENT_SECRET,
      audience: `https://${event.secrets.DOMAIN}/api/v2/`
    }
  };

```

This example is for PostUserRegistration, i am trying to do the same for PostLogin,

a) url: `https://${event.secrets.DOMAIN}/oauth/token`,  
As i have a custom hostname, i should gave the domain of the custom hostname([auth.mysite.com](http://auth.mysite.com)) instead of my tenant (dev-xxxx) ?  
b) event.secrets.CLIENT\_ID and event.secrets.CLIENT\_SECRET are retrieved from the event or those information i take from auth0\>application\> ?  
I guess it is from auth0\>application\>basic information because when i do console.log(event.secrets) it’s empty.

Thanks a lot for your help !

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 6, 2023, 10:02pm UTC](https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794/3 "2023-02-06T22:02:13Z")

</div>

Hi @Neos,

Thanks for reaching out to the Auth0 Community!

After taking a look at your Universal Login settings, I found that you are trying to use the Management API in Actions.

I recommend reading the [How can I use the Management API in Actions?](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947) FAQ which explains in detail how to accomplish this.

Just to touch on the `event.secrets`, these are sensitive values that are saved in the Action’s **Secrets** section depicted by a Key icon. See below:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/5/d/5d04a0fa6fb044937cc2c66746559d98fa53d266.jpeg)

After adding the `client_id`, `client_secret`, and `domain` Secrets, you can call them inside the script with the `event.secrets` prefix.

(Reference: [Write Your First Action - Add a Secret](https://auth0.com/docs/customize/actions/write-your-first-action#add-a-secret))

I hope this helps!

Please let me know how this goes for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![Neos](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neos/32/34386_2.png) [@Neos](https://community.auth0.com/u/Neos)\
**Post date:** [February 6, 2023, 11:07pm UTC](https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794/4 "2023-02-06T23:07:30Z")

</div>

Thanks for your answer and the explanation for the event.secrets.  
I will try to be more clear of what i am trying to achieve.

I am using already machine to machine api for backend in nestJs and spa application for frontend. I am able to call from my frontend a protected url of the backend (nestJs).

My goal now is when the user sign up first time. In the action in postLogin, i want to send the userId generated from auth0 to to my api in backend which will add this user in my own database.  
So my objective, is to call an api from auth0 to my nest js backend which is for example the following one.  
This is the api that i expose in my backend, my frontend is able to call this api, but i need to call it from auth0 during the sing up, to send him the userId.  
@UseGuards(AuthGuard(‘jwt’))  
@Post(‘addiuser’)  
async insertUserId(  
@Body(‘userId’) userId: string,  
) {  
// code which add here this id to my database  
}  
1)I read the example [https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947) but it is to use ManagementClient to assign the roles right. Can i use the managementClient to call my external api (/adduser)?

2)I was thinking that this tutorial is what i am trying to do but on this tutorial i don’t see where you are adding the client\_id, client\_secret or the domain to generate a token access which i should attach to the api (/adduser) that i am going to call right ?  
[https://community.auth0.com/t/how-do-i-make-an-axios-api-call-and-store-it-as-a-custom-claim-using-actions/84491](https://community.auth0.com/t/how-do-i-make-an-axios-api-call-and-store-it-as-a-custom-claim-using-actions/84491)

3)Or should i proceed from the example which is here ?

> [@How do I call my API from an Action?](https://community.auth0.com/t/how-do-i-call-my-api-from-an-action/69041):
>
> Hey, So I’m in the process of trying to add a user to my database using an API call from a “Post User Registration” Action. I have followed this blog post here: and seem to have everything looking good. On top of that when I run the test it says the action was successful. The only problem is that my API is not being called at all even though I have triple checked that the URL is correct. Here is the code I’m working with: import axios from "axios"; exports.onExecutePostUserRegistration = …

I was trying the third, please let me know if i am on the wrong way ?  
So i want to call from auth0 during the sing up, in post login, a endpoint that i created in my backend. To be able to call this endpoint i would need to attach the baerer token right ?

---

<div class="post-metadata">

**Author:** ![Neos](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neos/32/34386_2.png) [@Neos](https://community.auth0.com/u/Neos)\
**Post date:** [February 7, 2023, 3:43pm UTC](https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794/6 "2023-02-07T15:43:47Z")

</div>

@rueben.tiow i finally was able to call my external api on actions on post login, anway thanks for explanation regarding the mangament Api 🙂

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 7, 2023, 4:31pm UTC](https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794/7 "2023-02-07T16:31:07Z")

</div>

Hi @Neos,

Thank you for your responses.

I’m glad you were able to call your external API in a Post Login Action!

Please reach out again if you have any further questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 8, 2024, 12:25pm UTC](https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794/8 "2024-01-08T12:25:00Z")

</div>

Hey there!

As this topic is related to Actions and Rules & Hooks are being deprecated soon in favor of Actions, I’m excited to let you know about our next [Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043) on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

[Learn more here!](https://community.auth0.com/t/auth0-community-ask-me-anything-rules-hooks-and-why-actions-matter/124043)

---

<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:** [September 7, 2024, 12:48am UTC](https://community.auth0.com/t/what-is-the-options-client-id-secret-to-send-to-make-an-api-call-in-action-after-post-login-onexecutepostlogin/99794/9 "2024-09-07T00:48:37Z")

</div>

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