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);
});









share|improve this question
























  • Probably similar to stackoverflow.com/questions/48477625/…
    – Günter Zöchbauer
    Nov 19 at 7:04















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);
});









share|improve this question
























  • Probably similar to stackoverflow.com/questions/48477625/…
    – Günter Zöchbauer
    Nov 19 at 7:04













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);
});









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?