API Key for accessing public Google Cloud Storage buckets

Viewed 262

I currently have a storage bucket that is public, however I would like to restrict access to the bucket to those that have specific access keys. I am wondering whether there is a way to configure this in Google Cloud rather than building a service around this use case.

1 Answers

API authentication

Cloud Storage uses OAuth 2.0 for API authentication and authorization. To make requests using OAuth 2.0 to either the Cloud Storage XML API or JSON API, include your application's access token in the Authorization header in every request that requires authentication. You can generate an access token from the OAuth 2.0 Playground:

  1. In the OAuth 2.0 Playground, click Cloud Storage API v1, and then select an access level for your application (full_control, read_only, or read_write).

  2. Click Authorize APIs.

  3. Sign in to your Google account when prompted. In the dialogue that appears, click Allow.

  4. In Step 2 of the playground, click Exchange authorization code for tokens for the authorization code that appears.

  5. Copy your access token and include it in the Authorization header of your request:

Authorization: Bearer OAUTH2_TOKEN

For full guide and other reference you can on below:

Cloud Storage authentication

Setting up authentication

Related