Exchange Auth Code in a Request for an Access Token

Share this video with your friends

Send Tweet

We're going to refactor some of our HTTP application code in order to create the ability to exchange the code inside our HTTP request for a token.

We can do this by creating a function that takes the code from a request and posts a query that contains our client id and secret to our token endpoint. We then await a response, parse the data from the response, and then return the parsed data.