Google api 如何使用angular dart auth_browser隐式流检索Google认证用户范围信息
我试图遵循dart+google auth getting started(),但很难找到对javascript sdk工具包()的类似调用 什么是等效的isSignedIn,您如何访问所请求的范围详细信息,如用户配置文件/电子邮件信息 我认为这可以通过调用peoples api来实现,但没有成功Google api 如何使用angular dart auth_browser隐式流检索Google认证用户范围信息,google-api,google-oauth,angular-dart,google-iam,Google Api,Google Oauth,Angular Dart,Google Iam,我试图遵循dart+google auth getting started(),但很难找到对javascript sdk工具包()的类似调用 什么是等效的isSignedIn,您如何访问所请求的范围详细信息,如用户配置文件/电子邮件信息 我认为这可以通过调用peoples api来实现,但没有成功 import 'package:angular/angular.dart'; import 'package:googleapis_auth/auth_browser.dart' as authBr
import 'package:angular/angular.dart';
import 'package:googleapis_auth/auth_browser.dart' as authBrowser;
import 'package:googleapis_auth/auth.dart' as auth;
import 'dart:developer';
@Injectable()
class AuthService {
static final _clientId = "hidden-.apps.googleusercontent.com";
static final _secret = "";
final List<String> _googleScopes = ["email","profile", "openid"];
static final _identifier = new authBrowser.ClientId(_clientId, _secret);
signIn(event) {
return authBrowser
.createImplicitBrowserFlow(_identifier, _googleScopes)
.then((authBrowser.BrowserOAuth2Flow flow) {
debugger();
flow
.clientViaUserConsent()
.then((auth.AutoRefreshingAuthClient client) {
final _test = await client.get(
'https://people.googleapis.com/v1/people/me',
); //returns 403 error, and subsequent no authorization header present
print(client);
});
});
}
}
可能类似于
flow
.clientViaUserConsent()
.then((auth.AuthClient client) async {
debugger();
await new PeopleApi(client).people
.get('people/me', personFields: 'coverPhotos,emailAddresses')
.then( (Person person) {
print(person);
});