Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update example apps
  • Loading branch information
ditman committed Dec 7, 2023
commit 2e10ba13ffcc627601514702110bd8427ec6b75a
8 changes: 4 additions & 4 deletions packages/google_identity_services_web/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:google_identity_services_web/id.dart';
// #docregion use-loader
import 'package:google_identity_services_web/loader.dart' as gis;
// #enddocregion use-loader
import 'package:js/js.dart' show allowInterop;

import 'src/jwt.dart' as jwt;

Expand All @@ -20,13 +19,14 @@ void main() async {
id.setLogLevel('debug');

final IdConfiguration config = IdConfiguration(
client_id: 'your-client_id.apps.googleusercontent.com',
callback: allowInterop(onCredentialResponse),
client_id:
'451137223537-t8qp8tl992tgqj5focnc6mh8cp2psn8g.apps.googleusercontent.com',
callback: onCredentialResponse,
use_fedcm_for_prompt: true,
);

id.initialize(config);
id.prompt(allowInterop(onPromptMoment));
id.prompt(onPromptMoment);
// #docregion use-loader
}
// #enddocregion use-loader
Expand Down
22 changes: 10 additions & 12 deletions packages/google_identity_services_web/example/lib/main_oauth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import 'package:google_identity_services_web/id.dart';
import 'package:google_identity_services_web/loader.dart' as gis;
import 'package:google_identity_services_web/oauth2.dart';
import 'package:http/http.dart' as http;
import 'package:js/js.dart' show allowInterop;
import 'package:js/js_util.dart' show getProperty;

/// People API to return my profile info...
const String MY_PROFILE =
Expand All @@ -38,15 +36,16 @@ void main() async {
id.setLogLevel('debug');

final TokenClientConfig config = TokenClientConfig(
client_id: 'your-client_id.apps.googleusercontent.com',
scope: scopes.join(' '),
callback: allowInterop(onTokenResponse),
error_callback: allowInterop(onError),
client_id:
'451137223537-t8qp8tl992tgqj5focnc6mh8cp2psn8g.apps.googleusercontent.com',
scope: scopes,
callback: onTokenResponse,
error_callback: onError,
);

final OverridableTokenClientConfig overridableCfg =
OverridableTokenClientConfig(
scope: (scopes + myConnectionsScopes).join(' '),
scope: scopes + myConnectionsScopes,
);

final TokenClient client = oauth2.initTokenClient(config);
Expand All @@ -59,8 +58,8 @@ void main() async {
///
/// We cannot use the proper type for `error` here yet, because of:
/// https://github.com/dart-lang/sdk/issues/50899
Future<void> onError(Object? error) async {
print('Error! ${getProperty(error!, "type")}');
Future<void> onError(GoogleIdentityServicesError? error) async {
print('Error! ${error?.type} (${error?.message})');
}

/// Handles the returned (auth) token response.
Expand Down Expand Up @@ -88,12 +87,11 @@ Future<void> onTokenResponse(TokenResponse token) async {
print(contacts);

print('Revoking token...');
oauth2.revoke(token.access_token,
allowInterop((TokenRevocationResponse response) {
oauth2.revoke(token.access_token!, (TokenRevocationResponse response) {
print(response.successful);
print(response.error);
print(response.error_description);
}));
});
}

/// Gets from [url] with an authorization header defined by [token].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dependencies:
google_identity_services_web:
path: ../
http: ">=0.13.0 <2.0.0"
js: ^0.6.4

dev_dependencies:
build_runner: ^2.1.10 # To extract README excerpts only.
Expand Down