Refresh Access Token¶
Request a new access token using the refresh token.
Request Format¶
GET https://{apigw-address}/app-portal-service/v2.0/token/refresh
Request Parameters (URI)¶
Name |
Location (Path/Query) |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|---|
refreshToken |
Query |
Mandatory |
String |
The refresh token. Refer to Choose Organization to learn how to get the refresh token. |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
Data Struct |
The details of the new access token. |
Data Struct¶
Name |
Data Type |
Description |
---|---|---|
userId |
String |
The user ID. |
userName |
String |
The user name. |
currentOrgId |
String |
The current organization ID. |
currentOrgName |
String |
The current organization name. |
accessToken |
String |
The new access token. |
refreshToken |
String |
The new refresh token. |
refreshTokenExpire |
String |
The refresh token expiration time in UTC format. For time formats, refer to ISO8601 Standard Time Formats Used by UTC |
Samples¶
Request Sample¶
url: https://{apigw-address}/app-portal-service/v2.0/token/refresh?refreshToken=yourRefreshToken
method: GET
Return Sample¶
{
"code": 200,
"message": "",
"data": {
"userId": "yourUserId",
"userName": "portal_demo",
"currentOrgId": "yourOrgId",
"currentOrgName": "Portal Demo",
"accessToken": "yourBearerToken",
"refreshToken": "yourRefreshToken",
"refreshTokenExpire": 1571368315000
}
}
Java SDK Sample¶
public class AppPortalSdkTest{
@Test
public void refreshAccessTokenTest() {
RefreshTokenRequest refreshTokenRequest = new RefreshTokenRequest(refreshToken);
RefreshTokenResponse refreshTokenResponse = Poseidon.config(PConfig.init().appKey("your_access_key").appSecret("your_secret_key").debug())
.url("https://{apigw-address}").getResponse(refreshTokenRequest, RefreshTokenResponse.class);
System.out.println("Refresh token res: " + JSON.toJSONString(chooseOrganizationResponse));
assertNotNull("Response should not be null", refreshTokenResponse);
assertNotNull("Response data should not be null", refreshTokenResponse.data);
String newAccessToken = refreshTokenResponse.data.accessToken;
assertNotEquals("New access token should not equal original access token", "your_access_token", newAccessToken);
}
}