Refreshing an access token
Once an After expiration of the original received access token has been obtained, it , a refresh token can be used immediately to access the REST APIs. After a certain amount of time, the access token expires and the application needs to use the refresh token to renew the access token. Both therefresh token and the expiration time are obtained during the authentication phase. To renew an access token with a refresh token, use a POST to acquire a new access token. Send a HTTP POST request to https://app1pub.smappee.net/dev/v1/oauth2/token
Code Block |
---|
POST /dev/v1/oauth2/token HTTP/1.1 Host: app1pub.smappee.net Content-Type: application/x-www-form-urlencoded;charset=UTF-8 grant_type=refresh_token& refresh_token=[YOUR_REFRESH_TOKEN]& client_id=[YOUR_APP_ID]& client_secret=[YOUR_CLIENT_SECRET] |
A If the server processed your call successfully you will receive a HTTP OK error with the renewed access token and a new refresh token.
Just like with the original authentication call, the new access token should be present in the answer. Please note the refresh token and the associated expiration delay may change and their new values should be acquired :can be used to access the API calls and the refresh token can be used to refresh access after the expiry period of 36000 seconds.
Code Block |
---|
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 Cache-Control: no-store Pragma: no-cache { "access_token":"f73fd163-68da-3d90-95da-a7cf20b7f179", "expires_in":1080036000, "refresh_token":"6d01da8f-d0bd-3e55-bba9-1ab7a31d6fe5", } |
...