I want to access the contacts of authenticated user . I have got the refresh and access token from oauth playground. How do I use these tokens to call people's api?
In your case probably the easiest is to create an authentification flow as per documentation, whereby you hardcode the token.json
file yourself.
token.json
file, you will be redirected to an authorization URL where you have to authenticate with your account, so that a token file with your credentials will be created.token.json
file is the following:{"access_token":"XXXXXXXXXXXXXXX","refresh_token":"YYYYYYYYYY","scope":"https://www.googleapis.com/auth/ZZZZZZZZZ","token_type":"Bearer","expiry_date":UNIX TIMESTAMP IN SECONDS}
token.json
file yourselfAlternatively
oauth2Client
as described in the documentation for Authentication and authorization with OAuth2 and use the methodoauth2Client.setCredentials({
refresh_token: 'STORED_REFRESH_TOKEN'
});
to assign to the oauth2Client
a refresh token manually.