# Device Flow: modify a returned claim in the login flow using a custom action

**URL:** <https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259>\
**Category:** Get Help\
**Tags:** device-flow\
**Created:** [October 28, 2021, 4:56pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259 "2021-10-28T16:56:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sean.feldman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sean.feldman/32/34527_2.png) [@sean.feldman](https://community.auth0.com/u/sean.feldman)\
**Post date:** [October 28, 2021, 4:56pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/1 "2021-10-28T16:56:25Z")

</div>

I’m using a device flow scenario to execute some migrations. Those migrations are executed by a given user and the user info is getting stamped on the migrated data. What I’d like to do is to augment one of the user claims, name, to include the fact that it was a device flow/migration. I cannot find any information on how to do that using custom actions. The only sample I’ve seen was using legacy rules that are a) discouraged and b) couldn’t get it working (no IntelliSense to get an idea what’s available on those objects passed in). Is there a way to achieve what I’m looking for that is documented?

---

<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:** [October 29, 2021, 8:11pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/3 "2021-10-29T20:11:46Z")

</div>

Hi @sean.feldman,

Thanks for reaching out to the Auth0 Community.

> [@sean.feldman](#):
>
> The only sample I’ve seen was using legacy rules that are a) discouraged and b) couldn’t get it working (no IntelliSense to get an idea what’s available on those objects passed in). Is there a way to achieve what I’m looking for that is documented?

First, could you please share the samples you found showing how to do this with Rules?

I’d like to take a look and see if it can be implemented in an Action script.

Thank you.

---

<div class="post-metadata">

**Author:** ![sean.feldman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sean.feldman/32/34527_2.png) [@sean.feldman](https://community.auth0.com/u/sean.feldman)\
**Post date:** [October 29, 2021, 9:01pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/4 "2021-10-29T21:01:47Z")

</div>

Hi @rueben.tiow,

The documentation for an Auth0 Application setup, under Device Authorization Flow

 ![image](https://global.discourse-cdn.com/auth0/original/3X/d/c/dc0e5738b9f9e85f4bab3618a983d0608a5a8fd7.png)

---

<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:** [November 4, 2021, 7:16pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/6 "2021-11-04T19:16:41Z")

</div>

Hi @sean.feldman,

Thank you for your response.

To accomplish a Device Authorization Flow using Actions, you can implement the following in a **Post-Login Action** script:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (event.transaction.protocol === 'oauth2-device-code') {
    ...
  }
}

```

You may also find the Post-Login [Event Object](https://auth0.com/docs/actions/triggers/post-login/event-object) and [API Object](https://auth0.com/docs/actions/triggers/post-login/api-object) documentation useful.

Please let me know if there’s anything else I can do to help.

Thank you.

---

<div class="post-metadata">

**Author:** ![sean.feldman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sean.feldman/32/34527_2.png) [@sean.feldman](https://community.auth0.com/u/sean.feldman)\
**Post date:** [November 4, 2021, 7:24pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/7 "2021-11-04T19:24:58Z")

</div>

@rueben.tiow, thank you so much for digging this information up. I’ll definitely try it out, and if not commenting back then, I’ve had great success, as Borat would say.

Appreciate your help. Any chance this could be added to the documentation when enabling device flow to replace the outdated docs/references?

---

<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:** [November 4, 2021, 9:57pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/8 "2021-11-04T21:57:20Z")

</div>

Hi @sean.feldman,

Thank you for your response!

Yes! The Action script sample code will be added to our documentation as we get closer to the end of life of Rules. At that point, all of our documentation will be include examples using Actions instead of Rules.

Please let me know if there are any other questions or concerns.

Thank you.

---

<div class="post-metadata">

**Author:** ![sean.feldman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sean.feldman/32/34527_2.png) [@sean.feldman](https://community.auth0.com/u/sean.feldman)\
**Post date:** [November 5, 2021, 10:40pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/9 "2021-11-05T22:40:15Z")

</div>

And it worked. Thank you so much 🙂

---

<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:** [November 5, 2021, 10:55pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/10 "2021-11-05T22:55:46Z")

</div>

Hi @sean.feldman,

I’m happy to hear that it works!

Please don’t hesitate to let me know if there’s anything else I can do to assist.

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:** [November 20, 2021, 10:55pm UTC](https://community.auth0.com/t/device-flow-modify-a-returned-claim-in-the-login-flow-using-a-custom-action/72259/11 "2021-11-20T22:55:53Z")

</div>

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