Exercise 3 Refreshtokens 1629384895590
Exercise 3 Refreshtokens 1629384895590
Description
In this exercise you’ll learn how to obtain a refresh token and use it to get new access tokens.
Estimated Duration
15
Instructions
Make sure you’ve completed the first Getting Started exercise, as you’ll need the account and
setup steps in that exercise to be complete first.
The goal of this exercise is to get a refresh token and use the refresh token to get a new access
token. We will be building on the previous exercise where you used the authorization code flow
to get an access token. Rather than repeat all the setup steps here, we’ll assume you have
already done that exercise.
Now you’ll want to start a new OAuth flow and request a refresh token. Build the authorization
URL like you did in the previous lesson, but this time also add the scope offline_access to the
request.
https://dev-xxxxxx.okta.com/oauth2/default/v1/authorize?
response_type=code&
scope=offline_access+{YOUR_SCOPE}&
client_id={YOUR_CLIENT_ID}&
state={RANDOM_STRING}&
redirect_uri=https://example-app.com/redirect&
code_challenge={YOUR_CODE_CHALLENGE}&
code_challenge_method=S256
If everything worked, you’ll get back a response that includes both an access token as well as a
refresh token! Paste the entire token response (not just the access token) into the oauth.school
website to check your work.
If that succeeds, you’ll be taken to the next step. Now you’ll need to use the refresh token to get
a new access token.
Make a POST request to the token endpoint again, but this time you’ll use new parameters to
make the refresh token request.
You should get back a new access token response, which will look similar to the previous
response except this will include a new access token. Paste the entire response into the field to
check the result!
If that worked, you’ll get a message saying you’ve completed the exercise!