BoxlangLicenseRefresh
Refreshes an existing BoxLang license token. This function uses the stored refresh token to obtain a new access token from the licensing server, extending the validity of the license without requiring manual re-activation.
Method Signature
BoxlangLicenseRefresh()Arguments
No arguments. This function uses the stored refresh token from the active license.
Return Value
Returns a STRUCT with the following keys:
success(BOOLEAN) - Whether the refresh was successfulmessage(STRING) - Status message or error descriptionisValidLicense(BOOLEAN) - Whether the license is now validisTrialMode(BOOLEAN) - Whether the system is in trial modeexpirationDate(STRING) - New license expiration datelicenseType(STRING) - Type of license:BoxLang+orBoxLang++
Examples
Template Syntax
// Refresh the active license token
<bx:script>
try {
result = boxlangLicenseRefresh();
if ( result.success ) {
writeOutput( "License token refreshed successfully!" );
writeOutput( "New Expiration: " & result.expirationDate );
} else {
writeOutput( "Refresh failed: " & result.message );
}
} catch ( Exception e ) {
writeOutput( "Error refreshing license: " & e.message );
}
</bx:script>Script Syntax
// Refresh license with error handling
try {
refreshResult = boxlangLicenseRefresh();
if ( refreshResult.success ) {
systemOutput( "✓ License refreshed successfully" );
systemOutput( "Expiration: " & refreshResult.expirationDate );
} else {
systemOutput( "✗ Refresh failed: " & refreshResult.message );
throw new Exception( refreshResult.message );
}
} catch ( Exception e ) {
systemOutput( "Exception: " & e.message );
}Scheduled Refresh Example
// Scheduled task to refresh license weekly
scheduledTask = {
name = "RefreshBoxLangLicense",
task = () => {
licenseInfo = boxlangLicenseInfo();
// Only refresh if license is active
if ( licenseInfo.isValidLicense ) {
try {
result = boxlangLicenseRefresh();
systemOutput( "[" & now() & "] License refresh: " & result.message );
} catch ( Exception e ) {
systemOutput( "[ERROR] License refresh failed: " & e.message );
}
}
},
// Run every Monday at 2:00 AM
schedule = "0 2 ? * MON"
};Combined License Management Example
// Complete license management workflow
function manageLicense() {
licenseInfo = boxlangLicenseInfo();
// Check license status
if ( licenseInfo.isValidLicense ) {
systemOutput( "License Status: Active" );
// Attempt to refresh token proactively
try {
refreshResult = boxlangLicenseRefresh();
if ( refreshResult.success ) {
systemOutput( "License token refreshed" );
}
} catch ( Exception e ) {
systemOutput( "License refresh failed: " & e.message );
// If refresh fails, may need reactivation
systemOutput( "Please contact Ortus Support" );
}
} else if ( licenseInfo.isTrialMode ) {
systemOutput( "Trial Mode Active - activation required" );
} else {
systemOutput( "No valid license - activation required" );
}
}Related
BoxlangLicenseInfo()- Get current license status and informationBoxlangLicenseActivate()- Activate a new license with email and key
Last updated
Was this helpful?
