How to retrieve Google authenticated users scope information using angular dart auth_browser implicit flow
up vote
0
down vote
favorite
I'm trying to follow this dart + google auth getting started ( https://github.com/dart-lang/googleapis_auth ) but I'm having a difficult time finding similar calls to the javascript sdk kit ( https://developers.google.com/api-client-library/javascript/samples/samples#authorizing-and-making-authorized-requests )
What is the equivalent isSignedIn, and how do you access the scope details requested, like user profile / email information?
I thought this might be done by calling to the peoples api but am not successful
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);
});
});
}
}
Edit: I did want to add the documentation says: "The authenticated HTTP client can now access data on behalf a user for the requested oauth2 scopes", but I cant see how this is achieved. Goal is just check if a user is signed in, and grab their email address they signed in with.
Edit 2: I managed to make a little ground I believe, and pulled in this to create a new PeopleApi client, but then this kicks out two errors:
dart_sdk.js:15886 Refused to set unsafe header "user-agent"
dart_sdk.js:15886 Refused to set unsafe header "content-length"
flow
.clientViaUserConsent()
.then((auth.AuthClient client) async {
debugger();
await new PeopleApi(client).people
.get('people/me', personFields: 'coverPhotos,emailAddresses')
.then( (Person person) {
print(person);
});
google-api google-oauth gcloud angular-dart google-iam
add a comment |
up vote
0
down vote
favorite
I'm trying to follow this dart + google auth getting started ( https://github.com/dart-lang/googleapis_auth ) but I'm having a difficult time finding similar calls to the javascript sdk kit ( https://developers.google.com/api-client-library/javascript/samples/samples#authorizing-and-making-authorized-requests )
What is the equivalent isSignedIn, and how do you access the scope details requested, like user profile / email information?
I thought this might be done by calling to the peoples api but am not successful
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);
});
});
}
}
Edit: I did want to add the documentation says: "The authenticated HTTP client can now access data on behalf a user for the requested oauth2 scopes", but I cant see how this is achieved. Goal is just check if a user is signed in, and grab their email address they signed in with.
Edit 2: I managed to make a little ground I believe, and pulled in this to create a new PeopleApi client, but then this kicks out two errors:
dart_sdk.js:15886 Refused to set unsafe header "user-agent"
dart_sdk.js:15886 Refused to set unsafe header "content-length"
flow
.clientViaUserConsent()
.then((auth.AuthClient client) async {
debugger();
await new PeopleApi(client).people
.get('people/me', personFields: 'coverPhotos,emailAddresses')
.then( (Person person) {
print(person);
});
google-api google-oauth gcloud angular-dart google-iam
Probably similar to stackoverflow.com/questions/48477625/…
– Günter Zöchbauer
Nov 19 at 7:04
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to follow this dart + google auth getting started ( https://github.com/dart-lang/googleapis_auth ) but I'm having a difficult time finding similar calls to the javascript sdk kit ( https://developers.google.com/api-client-library/javascript/samples/samples#authorizing-and-making-authorized-requests )
What is the equivalent isSignedIn, and how do you access the scope details requested, like user profile / email information?
I thought this might be done by calling to the peoples api but am not successful
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);
});
});
}
}
Edit: I did want to add the documentation says: "The authenticated HTTP client can now access data on behalf a user for the requested oauth2 scopes", but I cant see how this is achieved. Goal is just check if a user is signed in, and grab their email address they signed in with.
Edit 2: I managed to make a little ground I believe, and pulled in this to create a new PeopleApi client, but then this kicks out two errors:
dart_sdk.js:15886 Refused to set unsafe header "user-agent"
dart_sdk.js:15886 Refused to set unsafe header "content-length"
flow
.clientViaUserConsent()
.then((auth.AuthClient client) async {
debugger();
await new PeopleApi(client).people
.get('people/me', personFields: 'coverPhotos,emailAddresses')
.then( (Person person) {
print(person);
});
google-api google-oauth gcloud angular-dart google-iam
I'm trying to follow this dart + google auth getting started ( https://github.com/dart-lang/googleapis_auth ) but I'm having a difficult time finding similar calls to the javascript sdk kit ( https://developers.google.com/api-client-library/javascript/samples/samples#authorizing-and-making-authorized-requests )
What is the equivalent isSignedIn, and how do you access the scope details requested, like user profile / email information?
I thought this might be done by calling to the peoples api but am not successful
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);
});
});
}
}
Edit: I did want to add the documentation says: "The authenticated HTTP client can now access data on behalf a user for the requested oauth2 scopes", but I cant see how this is achieved. Goal is just check if a user is signed in, and grab their email address they signed in with.
Edit 2: I managed to make a little ground I believe, and pulled in this to create a new PeopleApi client, but then this kicks out two errors:
dart_sdk.js:15886 Refused to set unsafe header "user-agent"
dart_sdk.js:15886 Refused to set unsafe header "content-length"
flow
.clientViaUserConsent()
.then((auth.AuthClient client) async {
debugger();
await new PeopleApi(client).people
.get('people/me', personFields: 'coverPhotos,emailAddresses')
.then( (Person person) {
print(person);
});
google-api google-oauth gcloud angular-dart google-iam
google-api google-oauth gcloud angular-dart google-iam
edited Nov 18 at 22:14
asked Nov 18 at 9:21
james
165217
165217
Probably similar to stackoverflow.com/questions/48477625/…
– Günter Zöchbauer
Nov 19 at 7:04
add a comment |
Probably similar to stackoverflow.com/questions/48477625/…
– Günter Zöchbauer
Nov 19 at 7:04
Probably similar to stackoverflow.com/questions/48477625/…
– Günter Zöchbauer
Nov 19 at 7:04
Probably similar to stackoverflow.com/questions/48477625/…
– Günter Zöchbauer
Nov 19 at 7:04
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53359406%2fhow-to-retrieve-google-authenticated-users-scope-information-using-angular-dart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Probably similar to stackoverflow.com/questions/48477625/…
– Günter Zöchbauer
Nov 19 at 7:04