Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

ADC vs Service Account for OAuth2 token - Server to Server request

Hello,

   I am trying to access Google Cloud resources (VMs, Storage buckets) from my project using REST APIs, for which I need OAuth2 token. I can obtain those programmatically (Java) using ADC credentials and Service Account Credentials. 

   The issue i run into when using ADC credentials is, that i need to re-authenticate every day using "gcloud auth application-default login" to get a new refresh_token. Otherwise, I receive "invalid_grant" error.  That command needs to be run from CLI.  Is there a Java SDK/REST API corresponding to the CLI command "gcloud auth application-default login" ?

3 0 385
0 REPLIES 0
Top Labels in this Space
Top Solution Authors