Request New Token
🧠Overview - requestNewAccessToken
requestNewAccessToken
The requestNewAccessToken
API is used to proactively request a fresh JWT access token for the current authenticated session. This ensures that session expiration does not interrupt the user experience, especially in long-running sessions or background operations.
🎯 Purpose
To refresh a user’s JWT token before it expires without forcing a logout or reauthentication.
This API is helpful when the app detects that the current token is nearing expiry or if the user is about to initiate a secure transaction.
📱 UI Guidance
This API call typically runs silently in the background. No user interface is required. However, developers should provide feedback if the API fails and impacts the session.
📥 Request Parameters
Name | Type | Required | Description |
---|---|---|---|
reasonForRefresh | String | ✅ | A short label for why the token is being refreshed (e.g., "sessionIdle" or "secureOperation" ). |
📩 Sample Code (Platform-Specific)
React Native
RdnaClient.requestNewAccessToken("sessionIdle", (syncResponse) => {
if (syncResponse?.error?.shortErrorCode === 0) {
console.log("Access token refresh request submitted successfully.");
}
});
Flutter
rdnaClient.requestNewAccessToken("secureOperation");
Cordova
com.uniken.rdnaplugin.RdnaClient.requestNewAccessToken(
() => console.log("Token refresh request initiated"),
(err) => console.error("Failed to request new token", err),
["sessionIdle"]
);
Native Android
RDNAError error = rdna.requestNewAccessToken("sessionIdle");
if (error.getShortErrorCode() == 0) {
Log.d("REL-ID", "Token refresh requested");
}
Native iOS
[client requestNewAccessToken:@"sessionIdle"];
📤 Output
This API does not return the token directly. Instead, the SDK will emit theonAccessTokenRefreshed
event, which carries the refreshed token.
Make sure to implement that event handler to update your token store.
Updated 2 months ago