2

This excellent article explains well how to access Google Cloud Storage in C# using oAuth: Uploading objects to google cloud storage buckets in c#

I want to do very similar things, but do not want to authorize using my gmail account, but rather a keypair of some other set of tokens.

There is mention of API keys and service account in google documentation, but it's not very clear at all- too many kinds of accounts and authentication to make sense of.

Imagine this - I want to do exactly as in the article referenced, but without the OAuth. What alternative are there?

Note: we use GSuite.

neilH
  • 3,320
  • 1
  • 17
  • 38
Daniel Williams
  • 8,912
  • 15
  • 68
  • 107

1 Answers1

8

You could create a new service account with the required roles for your needs and generate a key file for that service account to use in your application. You can do this by following these steps.

1) Navigate to 'APIs & Services' > 'Credentials'

2) Click on 'Create credentials' > 'Service account key'

3) You have the option of selecting a service account that already exists, or creating a new service account (for the purpose of these steps I'll select 'create new service account')

4) Select a role that allows the access to the storage you require, for example 'Storage Admin' which allows read and write operations to the bucket(s).

5) Choose either JSON or P12 (JSON is recommended) and then hit 'Create'. The key file for the service account will be downloaded to your local machine.

The key file generated in the above steps can be used to allow application to assume the identity of the service account, and therefore it's authorisation/authentication privileges.

Admittedly, I am not too familiar with C# but the information here describes how to use a service account key file with various languages including C#.

neilH
  • 3,320
  • 1
  • 17
  • 38