# How do you get the connection metadata in an Action?

**URL:** <https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218>\
**Category:** Get Help\
**Created:** [February 2, 2021, 4:52pm UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218 "2021-02-02T16:52:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![fieldju](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fieldju/32/27337_2.png) [@fieldju](https://community.auth0.com/u/fieldju)\
**Post date:** [February 2, 2021, 4:52pm UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/1 "2021-02-02T16:52:44Z")

</div>

In a rule I could do the following

```javascript
const connectionMetadata: ArmoryConnectionMetadata = context.connectionMetadata || {}

```

In the actions I only see the following in the event.connection object

```typescript
/** Connection */
declare type Connection = {
  /** The connection's unique identifier. */
  id: string
  /** The name of the connection used to authenticate the user (such as: `twitter` or `some-g-suite-domain`). */
  name: string
  /**
   * The type of connection.
   *
   * For social connection `connectionStrategy === connection`.
   * For enterprise connections, the strategy will be `waad` (Windows Azure AD), `ad` (Active Directory/LDAP), `auth0` (database connections), and so on.
   */
  strategy: string
}

```

Is there a global client around where I can grab the connection metadata with the connection id?

ex: rules had this global around

```javascript
    await auth0.users.updateUserMetadata(user.user_id, {
      ...userMetadata,
      lastEnvId: requestedEnvironmentId
    })

```

Is there an `auth0.connections.getConnection(connectionId)` or something that can be used in an Action?

---

<div class="post-metadata">

**Author:** ![fieldju](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fieldju/32/27337_2.png) [@fieldju](https://community.auth0.com/u/fieldju)\
**Post date:** [February 2, 2021, 4:56pm UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/2 "2021-02-02T16:56:03Z")

</div>

In the mean time, I am gonna add `https://github.com/auth0/node-auth0` and the needed credentials via action secrets to get the metadata, but i’d much prefer if the connection metadata was in the event, just like it is in the rules.

Actions already have the app and user metadata but is only missing the connection metadata for some reason.

---

<div class="post-metadata">

**Author:** ![fieldju](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fieldju/32/27337_2.png) [@fieldju](https://community.auth0.com/u/fieldju)\
**Post date:** [February 2, 2021, 8:18pm UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/3 "2021-02-02T20:18:07Z")

</div>

So I added auth0 and it’s adding a brutal amount of latency because it has to auth and get a token and then call the API, so that’s 2 new requests in the auth chain ☹

Pretty please, add connection metadata to the event 🙏

 ![image](https://global.discourse-cdn.com/auth0/original/3X/0/8/08864cd8f347d63120adb1fb6b266441a9db0e93.png)  
☝ with Actions ~2000 ms to authenticate

 ![image](https://global.discourse-cdn.com/auth0/original/3X/a/e/aee389dee6fe46ee1dc8ad4087278c83292af735.png)  
☝ with rules \< half the time at ~900ms

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 2, 2021, 8:57pm UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/5 "2021-02-02T20:57:26Z")

</div>

@fieldju ,

Thanks for the feedback! I’ll pass the request along to the product team.

---

<div class="post-metadata">

**Author:** ![chris.geihsler](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.geihsler/32/27354_2.png) [@chris.geihsler](https://community.auth0.com/u/chris.geihsler)\
**Post date:** [February 2, 2021, 10:14pm UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/6 "2021-02-02T22:14:54Z")

</div>

Thanks for trying out actions @fieldju! We’ll get `event.connection.metadata` added. It’s only missing due to an oversight on our end. Sorry about that!

Also, our hope is that in the future it should be pretty rare that you’ll need to use the Auth0 client in an action, but when you do, we’ll have better ways of providing it to you than relying on you to bootstrap it yourself. Stay tuned for that.

And thanks again for the awesome feedback!

---

<div class="post-metadata">

**Author:** ![fieldju](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fieldju/32/27337_2.png) [@fieldju](https://community.auth0.com/u/fieldju)\
**Post date:** [February 3, 2021, 6:06am UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/7 "2021-02-03T06:06:33Z")

</div>

@chris.geihsler is that a next sprint type of thing or a next quarter type of thing?

I implemented my workflow 2x, one with hooks + rules and the other with actions.  
I am stashing the actions away on a branch for now, but would like to switch over to them one this is implemented because I like the UX of dev’ing actions better.

---

<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 18, 2021, 6:07am UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/8 "2021-02-18T06:07:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![darin.laframboise](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/darin.laframboise/32/23709_2.png) [@darin.laframboise](https://community.auth0.com/u/darin.laframboise)\
**Post date:** [March 25, 2021, 9:13pm UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/9 "2021-03-25T21:13:18Z")

</div>

This is probably a one quarter thing, I’m not sure we can solve it in a sprint. I want to make sure we solve caching correctly.

---

<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:** [March 26, 2021, 8:26am UTC](https://community.auth0.com/t/how-do-you-get-the-connection-metadata-in-an-action/57218/10 "2021-03-26T08:26:48Z")

</div>

Thanks for following up on that Darin!
