AuthorizationResponse.fromRedirectUri constructor
AuthorizationResponse.fromRedirectUri(
- String redirectUri,
- String? checkState
)
Implementation
AuthorizationResponse.fromRedirectUri(
String redirectUri, String? checkState) {
queryParams = Uri.parse(redirectUri).queryParameters;
error = getQueryParam('error');
errorDescription = getQueryParam('error_description');
if (error == null) {
code = getQueryParam('code');
if (code == null) {
throw Exception('Expected "code" parameter not found in response');
}
// Only validate the state if the checkState was actually supplied
if (checkState != null && checkState.isNotEmpty) {
state = getQueryParam('state');
if (state == null) {
throw Exception('Expected "state" parameter not found in response');
}
if (state != checkState) {
throw Exception(
'"state" parameter in response doesn\'t correspond to the expected value');
}
}
}
}