0

I have scaffolded a web app which is able to register a user with Passportjs and Google Oauth2. While registering the user in the scopes I am asking for accessing the Google Plus API and retrieving the accessToken and refreshToken to be persisted in the MongoDB.

Later in the application I am trying to make an API call to retrieve Google Plus user profile to test . I am following the following steps in the code

var oAuth2 = googleCredentials.oauthClient(); // Setting a new Oauth2 // Client using Project credentials

then retrieving the access_token and refresh_token for this particular user and setting the credentials like below

oAuth2.setCredentials({
      access_tokens: user[0].access_token,
      refresh_tokens: user[0].refresh_token
    });

then making an API call

  plus.people.get({
      userId: 'me',
      auth: oAuth2
    }, function (err, response) {

      console.log(err);
      res.send(response);

    });

but my application errors logging the following error

[Error: No access or refresh token is set.]

Any help would be much appreciated

Anand
  • 121
  • 3
  • 12
  • I have even checked the validity of the access tokens by visiting the url https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=[my access token] and receive a positive response but really am not able to understand why does the API call always report an error a mentioned above. Any help is much appreciated – Anand Nov 14 '16 at 12:48

1 Answers1

1

Apologise for people who have spent time reading my code as it was such as obvious bummer . when setting the credentials I was passing plural words such as access_tokens instead of access_token and refresh_token. I spend an entire night trying to figure out the issue.

I am glad that I am able to proceed further.

Anand
  • 121
  • 3
  • 12