0

After login from client side and receive access token on the server side, I want to call Google API for taking info. Can I in server-side just call google API, without insert API key and another credential but only with the access token?

Something like that:

plus.people.get({
    resourceName: 'people/me',
    personFields: 'emailAddresses,names',
    auth: accessToken}, (err, response) => {
      console.log(response);
    });

I'm actually using node.js

3
  • You either need api-key or access-token with oauth clientId and clientSecret. Commented Jan 25, 2018 at 15:45
  • I insert access-token but the call returns undefined Commented Jan 25, 2018 at 15:54
  • console.log(err) ? Commented Jan 25, 2018 at 16:21

1 Answer 1

4

I understood that you want to use people.get using access token. If my understanding is correct, how about this sample script?

Sample script :

var google = require('googleapis');
var plus = google.people('v1');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2();
oauth2Client.setCredentials({access_token: accessToken});
plus.people.get({
    resourceName: 'people/me',
    personFields: 'emailAddresses,names',
    auth: oauth2Client}, (err, response) => {
      console.log(response);
    });

If I misunderstand your question, I'm sorry.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.