0

my question is can we bind roles to API Keys if so, how?

Are the API Keys supported for all the services across GCP if not which ones?

also, why to use service account over API keys?

from googleapiclient import discovery

storage_service = discovery.build('storage', 'v1', developerKey="AIzaSyhidingKeyVm60c")

storage_service.buckets().list(project='my-project').execute()
1
  • There are two major APIs (Google and Google Cloud). Google Cloud Storage does not support API Keys. API Keys are supported by some Google services (not Google Cloud services). See @DazWilkin's answer. Commented Mar 14, 2022 at 18:59

1 Answer 1

1

I encourage you to read Google's documentation, e.g. authentication overview, it is definitive and comprehensive.

API keys:

  • authenticate apps (not users).
  • are supported across Google's (not only Google Cloud Platform) services.
  • should be used judiciously if at all.
  • aren't used with roles.

Roles are an element of role-based access control (RBAC) and, with Google Cloud IAM (overview) are bound to users, service accounts and groups to define access policies.

Programs accessing data not owned by users should generally run as a service account.

Programs accessing data owned by users should authenticate using the user's credentials.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.