DEV Community

meddlesome
meddlesome

Posted on • Edited on

How to access Google Cloud Storage Bucket with Service account JSON

This method for gsutil to access Google Cloud Storage bucket with shared Service account with private key as JSON

Sample JSON Structure

{
  "type": "service_account",
  "project_id": "xxx",
  "private_key_id": "xxx",
  "private_key": "-----BEGIN PRIVATE KEY-----\name-----END PRIVATE KEY-----\n",
  "client_email": "xxx@xxx.iam.gserviceaccount.com",
  "client_id": "xxx",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xxx.iam.gserviceaccount.com"
}
Enter fullscreen mode Exit fullscreen mode
  1. Using gsutil config -e to set method to authentication
  2. Choose oAuth2 and provided full path of service account JSON file
  3. Then you can access with gsutil ls gs://{bucket-name}

Top comments (0)