oauth 2.0 - Exchange authorization_code for access_token and id_token not working using Auth0 -


i using auth0 sms passwordless login , can login correctly , redirected correctly specified callback url: http://localhost:8000/authenticated?code=authorization_code. have been following this tutorial when step 4 , 5 exchange authorization_code access_token , id_token getting error message back: {"error":"access_denied","error_description":"unauthorized"}.

this how sending code auth0 server through post:

var code = request.query.code; var url = `https://${process.env.auth0_client_domain}/oauth/token?client_id=${process.env.auth0_client_id}&redirect_uri=http://localhost:8000/authenticated&client_secret=${process.env.auth0_client_secret}&code=${code}&grant_type=authorization_code`;  wreck.post(url, (err, res, payload) => {   console.log(payload.tostring()); }); 

is there missing querystring? or need before sending post request?

my question answered in issue on auth0 repo: https://github.com/auth0/auth0.js/issues/234

but have reposted answer here:

post payload, not send params in query string:

var code = request.query.code; var url = `https://${process.env.auth0_client_domain}/oauth/token`; var body = {    client_id:process.env.auth0_client_id,   redirect_uri:'http://localhost:8000/authenticated',   client_secret:process.env.auth0_client_secret,   code:code,   grant_type:'authorization_code' };  wreck.post(url, {payload:body}, (err, res, payload) => {     console.log(payload.tostring()); }); 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -