4
votes

I am trying to use the google_plus_v1_api + google_oauth2_client within a chrome packaged app.

Everythin works fine when i am using only the oauth2 lib:

chrome.identity.getAuthToken(new chrome.TokenDetails(interactive:true))
.then((token){
       OAuth2 auth = new SimpleOAuth2(token);
       var request = new HttpRequest();
       request.onLoad.listen((d){print(request.response); 
       request.open('GET', 'https://www.googleapis.com/plus/v1/people/me');
       auth.authenticate(request).then((request) => request.send());
});

But i can't make google+ lib works:

chrome.identity.getAuthToken(new chrome.TokenDetails(interactive:true))
.then((token){
       OAuth2 auth = new SimpleOAuth2(token);
       Plus plus = new Plus(auth); 
       plus.people.get('me').then((d)=>print(d));
});

Return this exception:

GET https://www.googleapis.com/plus/v1/people/me 403 (Forbidden) Exception: APIRequestException: 403 Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.

Am i missing something? How am i supposed to use google+ api lib?

2
I remember getting this when using an invalid API key. No key normally works, but not an invalid key.Günter Zöchbauer

2 Answers

3
votes

I just saw your answer, but wanted to point out I had the same problem and solved it by setting the makeAuthRequests property of the Plus client to true:

final plusclient.Plus plus = new plusclient.Plus(auth)
    ..makeAuthRequests = true;

Seems like a more straightfoward solution, since the auth object already contains the token. I would've expected makeAuthRequests to be automatically set to true when constructing a Plus client with an OAuth2 object, but apparently it's not (probably an oversight).

1
votes

Sorry, i figured out that this line was missing thanks to this tutorial :

plus.oauth_token = auth.token.data;

My google_plus_v1_api query is now working. Sorry for the inconvenience.