0
votes

I need to "Authenticating as an End User" (I to access resources on behalf of an end user of my application) in google cloud storage. Since my application is written in c++. I compiled c++ google cloud storage client library. But here it states that it needs client's JSON file in order to create gcs::Client object. I couldn't find any other way to create Client with information such as project id, service email, private key, key name and bucket name (These informations are enough to authenticate in python). Is there any way to authenticate an End user with the above information in google cloud storage c++ client library?

2

2 Answers

1
votes

In Google Cloud there are three types of credentials:

  • API Keys.
  • Service Account Credentials.
  • User Credentials (OAuth 2.0).

API Keys do not apply to your use case. These credentials are used for Google services that do not require identity.

The example code that you are referencing uses (requires) Service Account credentials which are stored as a Json file. This is the standard method of authenticating and authorizing software applications.

If your goal is to have your user authorize with their Google Account and use the OAuth 2.0 token in your software to access Google Cloud Storage, this can also be done. You will need to implement the Google OAuth 2.0 Flow in your application, which will launch a browser for the user. Google will callback to your code with the OAuth token.

C++ Using OAuth 2.0

Suggestion: If you have not done any development for OAuth 2.0 previously, I would not start with Google OAuth 2.0 development in C++. Use a language like Python which has lots of examples, so that you get a feeling for how OAuth works.

0
votes

When you say you are "Authenticating as an End User", do you mean the user will have an account in Google Cloud Platform and you are planning to use their credentials (maybe via OAuth to access Google Cloud Storage? If so, I am sorry to say we have not implemented support for that workflow in google-cloud-cpp.

I filed a bug to track this, feel free to add additional questions or suggestions there.