# ManagementClient and secrets with cli deployment

**URL:** <https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273>\
**Category:** Get Help\
**Tags:** actions-management-api, management-api\
**Created:** [July 14, 2023, 10:15am UTC](https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273 "2023-07-14T10:15:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![libor.vozdek](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/libor.vozdek/32/48843_2.png) [@libor.vozdek](https://community.auth0.com/u/libor.vozdek)\
**Post date:** [July 14, 2023, 10:15am UTC](https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273/1 "2023-07-14T10:15:34Z")

</div>

Hi,  
I’m working on a migration from Rules to Actions. One of the changes for me was a change in how we are initiating ManagementClient , I have used this help topic as my bases:  
[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)  
Setting up new application, and then storing the clientid and secret in action’s secrets. This works fine when I’m setting this manually.  
But now I need to set up deployment using a0deploy with the tenants.yaml.  
So for Application(client), it is easy:

```auto
clients:
  - name: XYZClientManagement
    app_type: non_interactive
...

```

but for the action, how do I now reference the generated client\_id and client\_secret? I basically need something like this? Is it anyhow possible to setup?

```auto
actions:
  - name: XYZAction
    code: ../code.js
    secrets:
      - name: MANAGEMENT_CLIENT_CLIENT_ID
        value: ${client.XYZClientManagement.client_id}
      - name: MANAGEMENT_CLIENT_CLIENT_SECRET
        value: ${client.XYZClientManagement.client_secret}

```

Thank you very much

---

<div class="post-metadata">

**Author:** ![jsteinbrunner](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jsteinbrunner/32/60041_2.png) [@jsteinbrunner](https://community.auth0.com/u/jsteinbrunner)\
**Post date:** [April 25, 2024, 10:25pm UTC](https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273/2 "2024-04-25T22:25:32Z")

</div>

Curious, if there are any recommendations for this? I’m also trying to instantiate a management client in an action, but do not want our client secret referenced in the auth0 deployment yamls.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 25, 2024, 10:47pm UTC](https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273/4 "2024-04-25T22:47:41Z")

</div>

Hey @jsteinbrunner - While I’m not _super_ familiar with deploy CLI it does look to be possible, here’s an example:

> <https://github.com/auth0/auth0-deploy-cli/blob/16dee06e5109e493e64a1895118a81c45206d554/examples/directory/actions/action-example.json#L11>

---

<div class="post-metadata">

**Author:** ![jsteinbrunner](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jsteinbrunner/32/60041_2.png) [@jsteinbrunner](https://community.auth0.com/u/jsteinbrunner)\
**Post date:** [April 26, 2024, 1:44pm UTC](https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273/5 "2024-04-26T13:44:08Z")

</div>

Thanks for the response @ty.frith!

I found a related post on this topic where @rueben.tiow referenced the same example yaml configuration.

> [@Auth0-deploy-cli directory configuration: Add secrets to action](https://community.auth0.com/t/auth0-deploy-cli-directory-configuration-add-secrets-to-action/78262/3):
>
> Hi @kamal.nellipudi, Welcome to the Auth0 Community! Yes, it is possible! To do so, you will need to use the tenant.yaml approach and specify the key-value pairs in the secrets object. See below: actions: - name: action-example code: ./actions/action-example/code.js dependencies: - name: lodash version: 4.17.21 deployed: true secrets: - name: MY\_SECRET value: \_VALUE\_NOT\_SHOWN\_ status: built supported\_triggers: - id: post-login …

Given his reply, it makes me think `_VALUE_NOT_SHOWN_` is static placeholder text for the purpose of the example.

If you know of any other resources that talk more about using secrets in the deploy tool, I would love to take a look.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 26, 2024, 8:56pm UTC](https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273/6 "2024-04-26T20:56:31Z")

</div>

Happy to help!

> [@jsteinbrunner](#):
>
> Given his reply, it makes me think `_VALUE_NOT_SHOWN_` is static placeholder text for the purpose of the example.

I was just able to run the Deploy CLI successfully and create an action with a secret as shown in the example - Both my application’s `client_secret` and Action `secret` were set using [environment variables](https://auth0.com/docs/deploy-monitor/deploy-cli-tool/configure-the-deploy-cli#environment-variables). Here’s my `tenant.yaml`:

```auto
actions:
  - name: action-deploy
    code: /Users/me/auth0-dev/test/deploy-cli/code.js
    deployed: true
    secrets:
      - name: MY_SECRET
        value: "#{env.MY_SECRET_VALUE}"
    status: built
    supported_triggers:
      - id: post-login
        version: v2

```

---

<div class="post-metadata">

**Author:** ![jsteinbrunner](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jsteinbrunner/32/60041_2.png) [@jsteinbrunner](https://community.auth0.com/u/jsteinbrunner)\
**Post date:** [April 26, 2024, 9:22pm UTC](https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273/7 "2024-04-26T21:22:58Z")

</div>

This is super helpful, thank you!

---

<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:** [May 10, 2024, 9:23pm UTC](https://community.auth0.com/t/managementclient-and-secrets-with-cli-deployment/111273/8 "2024-05-10T21:23:48Z")

</div>

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