# Node JS Authorization code grant question

**URL:** <https://community.auth0.com/t/node-js-authorization-code-grant-question/8219>\
**Category:** Get Help\
**Tags:** authorization-code-f\
**Created:** [September 17, 2017, 12:20pm UTC](https://community.auth0.com/t/node-js-authorization-code-grant-question/8219 "2017-09-17T12:20:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramez555](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ramez555](https://community.auth0.com/u/ramez555)\
**Post date:** [September 17, 2017, 12:20pm UTC](https://community.auth0.com/t/node-js-authorization-code-grant-question/8219/1 "2017-09-17T12:20:02Z")

</div>

Here is the scenario I would like to achieve:

- User authenticated using:  
router.get(‘/login’, passport.authenticate(‘auth0’, {  
clientID: env.AUTH0\_CLIENT\_ID,  
domain: env.AUTH0\_DOMAIN,  
redirectUri: env.AUTH0\_CALLBACK\_URL,  
responseType: ‘code’,  
audience: ‘https://’ + env.AUTH0\_DOMAIN + ‘/userinfo’,  
scope: ‘openid profile’}),  
function(req, res) {  
res.redirect(“/”);  
});

- get the user profile and do some validation:  
router.get( ‘/callback’,  
passport.authenticate(‘auth0’, {  
failureRedirect: ‘/failure’  
}),  
function(req, res) {  
res.redirect(req.session.returnTo || ‘/user’);  
}  
);

- Send the authorization code received from the authentication process to 3rd party for an Authorization code grant.

The problem is, once my callback is called and this runs  
passport.authenticate(‘auth0’, {  
failureRedirect: ‘/failure’  
}),  
the authorization code is already been exchanged and I cannot use it again.  
How can I get another code to be used without the need to re authenticate the user again?  
I might be looking at this from a wrong way. The dilemma I need to capture the user profile before sending the code to the 3rd party.  
Appreciate your help guys been looking at this for the past 2 days ☹

---

<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:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/node-js-authorization-code-grant-question/8219/2 "2018-03-02T05:56:33Z")

</div>


