OAuth2 Exceptions API
The OAuth2Exceptions API can be used to create exceptions within JavaScript code within an OAuth2 context, e.g. within a Smart on FHIR Outbound onPostAuthorize callback.
Creates an UnauthorizedException.
Inputs:
theMessage
– The error messageOutputs:
Example:
throw OAuth2Exceptions.newUnauthorizedException('Account not processed yet, please try again tomorrow.');
This will return an HTTP 401 status code with the following response:
{
"error": "unauthorized",
"error_description": "Account not processed yet, please try again tomorrow."
}
Creates a ForbiddenException.
Inputs:
theMessage
– The error messageOutputs:
Example:
throw OAuth2Exceptions.newForbiddenException('Account not fully configured yet, please wait an hour and try again.');
This will return an HTTP 403 status code with the following response:
{
"error": "access_denied",
"error_description": "Account not fully configured yet, please wait an hour and try again."
}