Skip to content

Commit

Permalink
Handle Auth popup close
Browse files Browse the repository at this point in the history
  • Loading branch information
HE-LU committed Mar 21, 2024
1 parent ff1bd43 commit 2352910
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions googleapis_auth/lib/src/oauth2_flows/token_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,25 @@ Future<AccessCredentials> requestAccessCredentials({
completer.complete(creds);
}

void errorCallback(gis.GoogleIdentityServicesError? error) {
if (error != null) {
completer.completeError(
AuthenticationException(
error.type.toString(),
errorDescription: error.message,
errorUri:
'https://developers.google.com/identity/oauth2/web/reference/js-reference#TokenClientConfig',
),
);
}
}

final config = gis.TokenClientConfig(
callback: allowInterop(callback),
client_id: clientId,
scope: scopes.toList(),
prompt: prompt,
error_callback: allowInterop(errorCallback),
);

final client = gis.oauth2.initTokenClient(config);
Expand Down Expand Up @@ -125,13 +139,27 @@ Future<CodeResponse> requestAuthorizationCode({
));
}

void errorCallback(gis.GoogleIdentityServicesError? error) {
if (error != null) {
completer.completeError(
AuthenticationException(
error.type.toString(),
errorDescription: error.message,
errorUri:
'https://developers.google.com/identity/oauth2/web/reference/js-reference#TokenClientConfig',
),
);
}
}

final config = gis.CodeClientConfig(
callback: allowInterop(callback),
client_id: clientId,
scope: scopes.toList(),
state: state,
login_hint: hint,
hd: hostedDomain,
error_callback: allowInterop(errorCallback),
);

final client = gis.oauth2.initCodeClient(config);
Expand Down

0 comments on commit 2352910

Please sign in to comment.