Refresh tokens are used as a way to gain a new access token after the original access token has expired.
What is Needed?
If you are using a refresh token, this article is going to assume that a general understanding of what a refresh token is and how to use the OAuth2 endpoints.
Endpoint
HTTP/1.1 POST
/oauth/token
/oauth?=token
Parameters
- (required) grant_type – “refresh_token”
- (required) refresh_token – A Valid Refresh Token.
https://your-server.com/oauth/token?grant_type=refresh_token&refresh_token=xxx
The Return
The server will return JSON containing the following values on a successful refresh token request.
Parameters
- access_token – A new access token
- expires_in – The length of seconds from the time the access token was issued until the access_token becomes invalid.
- token_type
- scope
- *refresh_token – A new refresh token
* If a new refresh token is wanted in the return, the filter below will need to be added to your theme’s function file.
add_filter( 'wo_always_issue_new_refresh_token', '__return_true' );
Return
{ "access_token": "nziindid3if24vrjbp6cdzyxiuybrcjjsd6grks7", "expires_in": 234234, "token_type": "Bearer", "scope": "basic" "request_token": "khaskdjhkhasdnaiwbwsh123" }