Authenticating People API without UI

Viewed 403

I want to authenticate personal google account for people API to send get/post requests,

However, I have to avoid authenticating for API each time as there will a cron job using the API. One way is to authenticate the first time and then use the refresh token for the necessary requests until the account revokes access (by changing password or manually removing the permission console)

Could there be a way, such that I could avoid manual authentication completely since the cron job will run on server-side

Used Service account for the same but didn't get required results

1 Answers

See https://developers.google.com/identity/protocols/oauth2/web-server

You can give your application consent once (the first time), and set in the authorization parameters the optional access_type='offline'.

"Set the value to offline if your application needs to refresh access tokens when the user is not present at the browser. This is the method of refreshing access tokens described later in this document. This value instructs the Google authorization server to return a refresh token and an access token the first time that your application exchanges an authorization code for tokens."

Related