Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class FlutterAppauthPlugin
private static final String TOKEN_ERROR_CODE = "token_failed";
private static final String END_SESSION_ERROR_CODE = "end_session_failed";
private static final String NULL_INTENT_ERROR_CODE = "null_intent";
private static final String NULL_ACTIVITY_ERROR_CODE = "null_activity";
private static final String INVALID_CLAIMS_ERROR_CODE = "invalid_claims";
private static final String NO_BROWSER_AVAILABLE_ERROR_CODE = "no_browser_available";

Expand All @@ -74,6 +75,9 @@ public class FlutterAppauthPlugin

private static final String NULL_INTENT_ERROR_FORMAT =
"Failed to authorize: Null intent received";

private static final String NULL_ACTIVITY_ERROR_FORMAT =
"Failed to authorize: Null activity received";
private static final String NO_BROWSER_AVAILABLE_ERROR_FORMAT =
"Failed to authorize: No suitable browser is available";

Expand Down Expand Up @@ -466,6 +470,8 @@ private void performAuthorization(
authIntent, exchangeCode ? RC_AUTH_EXCHANGE_CODE : RC_AUTH);
} catch (ActivityNotFoundException ex) {
finishWithError(NO_BROWSER_AVAILABLE_ERROR_CODE, NO_BROWSER_AVAILABLE_ERROR_FORMAT, ex);
} catch (NullPointerException ex) {
finishWithError(NULL_ACTIVITY_ERROR_CODE, NULL_ACTIVITY_ERROR_FORMAT, ex);
}
}

Expand Down Expand Up @@ -576,7 +582,12 @@ private void performEndSessionRequest(
final EndSessionRequest endSessionRequest = endSessionRequestBuilder.build();
AuthorizationService authorizationService = getAuthorizationService();
Intent endSessionIntent = authorizationService.getEndSessionRequestIntent(endSessionRequest);
mainActivity.startActivityForResult(endSessionIntent, RC_END_SESSION);

try {
mainActivity.startActivityForResult(endSessionIntent, RC_END_SESSION);
} catch (NullPointerException ex) {
finishWithError(NULL_ACTIVITY_ERROR_CODE, NULL_ACTIVITY_ERROR_FORMAT, ex);
}
}

private AuthorizationService getAuthorizationService() {
Expand Down
Loading