# In a Rule is it possible to return the accessToken as an idToken?

**URL:** <https://community.auth0.com/t/in-a-rule-is-it-possible-to-return-the-accesstoken-as-an-idtoken/70673>\
**Category:** Get Help\
**Tags:** rules, auth0\
**Created:** [October 2, 2021, 12:09pm UTC](https://community.auth0.com/t/in-a-rule-is-it-possible-to-return-the-accesstoken-as-an-idtoken/70673 "2021-10-02T12:09:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![turbo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/turbo/32/30245_2.png) [@turbo](https://community.auth0.com/u/turbo)\
**Post date:** [October 2, 2021, 12:09pm UTC](https://community.auth0.com/t/in-a-rule-is-it-possible-to-return-the-accesstoken-as-an-idtoken/70673/1 "2021-10-02T12:09:16Z")

</div>

I would like to know if it is possible to return the accessToken in the idToken of a rule.  
This would be convenient to be able to fetch the access token from the user profile.  
Although I’m not sure if this is secure.

I tried doing

```auto
   context.idToken['https://app.twikies.com/token'] = context.accessToken;

```

but when I call the handleProfile function it sends me an empty object on that field `'https://app.twikies.com/token'`

I wonder if this is a security measure that the real accessToken isn’t exposed inside the rule

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [October 4, 2021, 2:53pm UTC](https://community.auth0.com/t/in-a-rule-is-it-possible-to-return-the-accesstoken-as-an-idtoken/70673/2 "2021-10-04T14:53:49Z")

</div>

HI @turbo

I would not do this. Access tokens are designed to be used in a very specific flow, and any time you go outside that flow, you introduce risks.

John

---

<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:** [October 19, 2021, 2:54pm UTC](https://community.auth0.com/t/in-a-rule-is-it-possible-to-return-the-accesstoken-as-an-idtoken/70673/3 "2021-10-19T14:54:26Z")

</div>

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