# Redirect from Rule - Missing id\_token in exchange response

**URL:** <https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145>\
**Category:** Get Help\
**Tags:** jwt, id\_token, redirect-rules\
**Created:** [January 13, 2021, 3:54pm UTC](https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145 "2021-01-13T15:54:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjungers](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sjungers/32/19971_2.png) [@sjungers](https://community.auth0.com/u/sjungers)\
**Post date:** [January 13, 2021, 3:54pm UTC](https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145/1 "2021-01-13T15:54:19Z")

</div>

Hi, I am testing out the redirect-from-rule functionality to do a bit of housekeeping for users during login. However, I’ve hit an issue that I don’t quite understand.

The rule is pretty simple for now:  
function (user, context, callback) {  
if (user.email === “[test@user.com](mailto:test@user.com)”) {  
console.debug(“Redirecting for admin”);  
context.redirect = { url: “[http://localhost:8086/redirect”](http://localhost:8086/redirect%E2%80%9D) };  
}  
return callback(null, user, context);  
}

The callback endpoint (“/redirect” above) doesn’t do anything yet and redirects back to /continue?state=… after it is complete. I am not yet exchanging anything between the rule and my app.

When this rule is enabled and I authenticate from a single page app (not sure about other application types), the token exchange does not include the id\_token even though I have the right scopes during login (opened, profile, email, etc). Does something get lost in the exchange? Am I supposed to return the id\_token back from the callback for this to work?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 13, 2021, 7:31pm UTC](https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145/3 "2021-01-13T19:31:09Z")

</div>

Hi @sjungers,

Are you by chance using Auth0 Developer Keys for the Social Connection you are using?

If so, it might be causing the issue with the Rules redirect. You can [set up the Social Connections](https://auth0.com/docs/connections/identity-providers-social) using your own credentials to see if this is the cause.

Here is a list of limitations of Auth0 Developer Keys: [Test Social Connections with Auth0 Developer Keys](https://auth0.com/docs/connections/social/devkeys#limitations-of-developer-keys-when-using-classic-universal-login)

---

<div class="post-metadata">

**Author:** ![sjungers](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sjungers/32/19971_2.png) [@sjungers](https://community.auth0.com/u/sjungers)\
**Post date:** [January 13, 2021, 7:47pm UTC](https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145/4 "2021-01-13T19:47:58Z")

</div>

We are not using any social connections or developer keys. Do I have to pass anything back to the rule for this to work? I thought it was odd that the id\_token attribute was missing after the exchange as if it lost track of the scopes I passed at the beginning of the login transaction.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 13, 2021, 9:06pm UTC](https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145/5 "2021-01-13T21:06:47Z")

</div>

Ah, okay!

I just tried out [redirect using rules](https://auth0.com/docs/rules/redirect-users), and I see that the user is not yet logged in when they hit the `/redirect` URL. I receive the id\_token only after completing authentication by redirecting to `/continue?state... `

`https://[YOUR DOMAIN OR CUSTOM DOMAIN]/continue?state=THE_ORIGINAL_STATE`

Just to clarify are you not receiving the id\_token after the `/continue?state=...` takes place?

---

<div class="post-metadata">

**Author:** ![sjungers](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sjungers/32/19971_2.png) [@sjungers](https://community.auth0.com/u/sjungers)\
**Post date:** [January 13, 2021, 9:33pm UTC](https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145/6 "2021-01-13T21:33:24Z")

</div>

Hi Stephanie,

It turns out we had a different rule interfering with the scopes in the request, though I’m not sure why that’s happening either. This can be closed.

---

<div class="post-metadata">

**Author:** ![sjungers](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sjungers/32/19971_2.png) [@sjungers](https://community.auth0.com/u/sjungers)\
**Post date:** [January 13, 2021, 9:43pm UTC](https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145/7 "2021-01-13T21:43:12Z")

</div>

I got to the bottom of the problem. It turns out we were customizing the scopes in a separate rule, and wound up removing requested scopes which was ok as long until the rule ran again on the callback. Skipping the rule execution when context.protocol === “redirect-callback” solved the issue. I’m sure there is still a problem with this rule, but at least its working “as expected” now with the redirect rule enabled.

---

<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:** [January 28, 2021, 9:43pm UTC](https://community.auth0.com/t/redirect-from-rule-missing-id-token-in-exchange-response/56145/8 "2021-01-28T21:43:20Z")

</div>

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