How Authentication Works - Refresh Tokens
We have had a lot of questions around getting started with authentication, so I wanted to make sure there are some materials that help explain this. The Webroot Unity API uses OAUTH 2 to generate Access and Refresh tokens. Each token has a different TTL, and is designed for specific usage. Best practices dictate that an access token should only be generated using GSM credentials once during development, and then after that, refresh tokens are used to keep the product authorized. Here are some flow charts to help explain how these different tokens are generated and used:
Initially, you will use your GSM credentials to generate your first Access token. This is a combination of your GSM username/password, and your API credentials that have been generated in the GSM console under Account Settings > API Access. (For more information on generating these credentials, please visit https://community.webroot.com/t5/Unity-API-KB/Getting-Started-with-the-Webroot-Unity-API-and-Postman/ta-p/274427)
Once this access token is generated, the GSM username/password combination may be removed from future authentication requests, and replaced with the refresh token, as shown above. Note that when using a refresh token for your /auth/token request, you will need to add the body key : value pairs of
refresh_token : {refresh token generated from access token}
grant_type : refresh_token
scope : *
Here is an example of the complete HTTP request for refreshing an access token with a refresh token:
POST /auth/token HTTP/1.1
Host: unityapi.webrootcloudav.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Authorization: Basic {access_token}
Cache-Control: no-cache
refresh_token={refresh_token}&grant_type=refresh_token&scope=*
Thanks!
Joseph
Initially, you will use your GSM credentials to generate your first Access token. This is a combination of your GSM username/password, and your API credentials that have been generated in the GSM console under Account Settings > API Access. (For more information on generating these credentials, please visit https://community.webroot.com/t5/Unity-API-KB/Getting-Started-with-the-Webroot-Unity-API-and-Postman/ta-p/274427)
Once this access token is generated, the GSM username/password combination may be removed from future authentication requests, and replaced with the refresh token, as shown above. Note that when using a refresh token for your /auth/token request, you will need to add the body key : value pairs of
refresh_token : {refresh token generated from access token}
grant_type : refresh_token
scope : *
Here is an example of the complete HTTP request for refreshing an access token with a refresh token:
POST /auth/token HTTP/1.1
Host: unityapi.webrootcloudav.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Authorization: Basic {access_token}
Cache-Control: no-cache
refresh_token={refresh_token}&grant_type=refresh_token&scope=*
Thanks!
Joseph
Reply
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.