When you are using same access token for some period, you may need to renew the old token due to expiration or security concerns. You can renew an access token using a refresh token, by a REST call with below curl command.
curl -k -d "grant_type=refresh_token&refresh_token=eaa3683b1cf78496b6c1e5b7ffc882&scope=PRODUCTION" -H "Authorization: Basic ME5fbXdWRXpTVnhfalJIbDV2cmc4RHIycHZBYTp0RmZjcHVFRFM5V1d2eFFEc1ZCd0tWVGd0dE1h, Content-Type: application/x-www-form-urlencoded" https://localhost:9443/oauth2/token
eaa3683b1cf78496b6c1e5b7ffc882 is a refresh token.
ME5fbXdWRXpTVnhfalJIbDV2cmc4RHIycHZBYTp0RmZjcHVFRFM5V1d2eFFEc1ZCd0tWVGd is the encoded value of <client_id>:<client_secret>. these value should be separated by colon(:).
https://localhost:9443/oauth2/token is the token endpoint url.
when you use above request, you may get this type of response
{"token_type":"bearer","expires_in":3600,"refresh_token":"eaa3683b1cf78496b6c1e5b7ffc882","access_token":"3812fa8e788d67e89d604b509c943921"}
When you use above curl command, you may need to do below configurations in identity.xml file which is located in below locations. This may change for different versions in IS.
IS 5.0.0 or less versions : <IS_HOME>/repository/conf directory
IS 5.1.0 : <IS_HOME>/repository/conf/identity/ directory
<!-- Default validity period for user access tokens in seconds -->
<AccessTokenDefaultValidityPeriod>3600</AccessTokenDefaultValidityPeriod>
<!-- Default validity period for application access tokens in seconds -->
<UserAccessTokenDefaultValidityPeriod>3600</UserAccessTokenDefaultValidityPerio>
<!-- Validity period for refresh token -->
<RefreshTokenValidityPeriod>84600</RefreshTokenValidityPeriod>
<!-- Enable renewal of refresh token for refresh_token grant -->
<RenewRefreshTokenForRefreshGrant>true</RenewRefreshTokenForRefreshGrant>
RenewRefreshTokenForRefreshGrant is set to 'true' by default and You can use Refresh Grant without modifying configurations.
Comments
Post a Comment