Google Cloud Authentication

I am working on the Google cloud platform and I need to access the cloud functions using a java non-web application, for example, I am trying to store and retrieve an object from Google cloud storage using the Google Cloud Storage JSON API.

Before contacting those who need to authenticate my application, I discovered that the authorization API has authorized access.

when I tried to get credentials from the Google Cloud platform, I get three credential options:

  • API Key
  • OAuth Client Id
  • Service account key

I have looked at the GCP documentation but am not getting clear information that is different from them, I am pretty much new to GCP, so could you please share a link to any information or blog that explains the type of these credentials with examples of Java programs that show how to use the Google Cloud client API .

+8
source share
1 answer

The Google Cloud Platform Virtual Platform Guide is the ultimate resource here:   https://cloud.google.com/docs/authentication

Google , , , .

API- , API- . , , . API , -. - API . , API .

, OAuth. OAuth - Google API. , - , , gcloud, -, - Google Cloud . . .

, . - , - , , . - , . , , . , , (, , gcloud gsutil).

Google Cloud Java library , " , auth, App Engine GCE. , gcloud.

Compute Engine, GCS:

Storage storage = StorageOptions.getDefaultInstance().getService();
Bucket bucket = storage.create(BucketInfo.of("myBucketName"));

, auth. . , , . .json , :

Storage storage = StorageOptions.newBuilder()
    .setProjectId(PROJECT_ID)
    .setCredentials(GoogleCredentials.fromStream(
        new FileInputStream(PATH_TO_JSON_KEY))).build();
Bucket bucket = storage.create(BucketInfo.of("myBucketName"));

!

+11

Source: https://habr.com/ru/post/1016781/


All Articles