Skip to content

Commit

Permalink
fix: do not hide PlatformException
Browse files Browse the repository at this point in the history
Previously if user manually closed web view it was not possible to indicate that.
  • Loading branch information
sidlatau committed Mar 25, 2024
1 parent 36f7e70 commit 5f61197
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions lib/oauth2_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,37 +152,33 @@ class OAuth2Client {
codeChallenge = OAuth2Utils.generateCodeChallenge(codeVerifier);
}

try {
var authResp = await requestAuthorization(
webAuthClient: webAuthClient,
clientId: clientId,
scopes: scopes,
codeChallenge: codeChallenge,
enableState: enableState,
state: state,
customParams: authCodeParams,
webAuthOpts: webAuthOpts);

if (authResp.isAccessGranted()) {
if (afterAuthorizationCodeCb != null) {
afterAuthorizationCodeCb(authResp);
}
var authResp = await requestAuthorization(
webAuthClient: webAuthClient,
clientId: clientId,
scopes: scopes,
codeChallenge: codeChallenge,
enableState: enableState,
state: state,
customParams: authCodeParams,
webAuthOpts: webAuthOpts);

tknResp = await requestAccessToken(
httpClient: httpClient,
//If the authorization request was successfull, the code must be set
//otherwise an exception is raised in the OAuth2Response constructor
code: authResp.code!,
clientId: clientId,
scopes: scopes,
clientSecret: clientSecret,
codeVerifier: codeVerifier,
customParams: accessTokenParams,
customHeaders: accessTokenHeaders);
} else {
tknResp = AccessTokenResponse.errorResponse();
if (authResp.isAccessGranted()) {
if (afterAuthorizationCodeCb != null) {
afterAuthorizationCodeCb(authResp);
}
} on PlatformException {

tknResp = await requestAccessToken(
httpClient: httpClient,
//If the authorization request was successful, the code must be set
//otherwise an exception is raised in the OAuth2Response constructor
code: authResp.code!,
clientId: clientId,
scopes: scopes,
clientSecret: clientSecret,
codeVerifier: codeVerifier,
customParams: accessTokenParams,
customHeaders: accessTokenHeaders);
} else {
tknResp = AccessTokenResponse.errorResponse();
}

Expand Down

0 comments on commit 5f61197

Please sign in to comment.