Search in sources :

Example 16 with IamCredentialsClient

use of com.google.cloud.iam.credentials.v1.IamCredentialsClient in project gapic-generator-java by googleapis.

the class AsyncGenerateIdToken method asyncGenerateIdToken.

public static void asyncGenerateIdToken() throws Exception {
    // It may require modifications to work in your environment.
    try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
        GenerateIdTokenRequest request = GenerateIdTokenRequest.newBuilder().setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString()).addAllDelegates(new ArrayList<String>()).setAudience("audience975628804").setIncludeEmail(true).build();
        ApiFuture<GenerateIdTokenResponse> future = iamCredentialsClient.generateIdTokenCallable().futureCall(request);
        // Do something.
        GenerateIdTokenResponse response = future.get();
    }
}
Also used : ArrayList(java.util.ArrayList) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) GenerateIdTokenRequest(com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest) GenerateIdTokenResponse(com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse)

Example 17 with IamCredentialsClient

use of com.google.cloud.iam.credentials.v1.IamCredentialsClient in project gapic-generator-java by googleapis.

the class SyncGenerateIdTokenStringListstringStringBoolean method syncGenerateIdTokenStringListstringStringBoolean.

public static void syncGenerateIdTokenStringListstringStringBoolean() throws Exception {
    // It may require modifications to work in your environment.
    try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
        String name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString();
        List<String> delegates = new ArrayList<>();
        String audience = "audience975628804";
        boolean includeEmail = true;
        GenerateIdTokenResponse response = iamCredentialsClient.generateIdToken(name, delegates, audience, includeEmail);
    }
}
Also used : ArrayList(java.util.ArrayList) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) GenerateIdTokenResponse(com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse)

Example 18 with IamCredentialsClient

use of com.google.cloud.iam.credentials.v1.IamCredentialsClient in project gapic-generator-java by googleapis.

the class SyncSignBlob method syncSignBlob.

public static void syncSignBlob() throws Exception {
    // It may require modifications to work in your environment.
    try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
        SignBlobRequest request = SignBlobRequest.newBuilder().setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString()).addAllDelegates(new ArrayList<String>()).setPayload(ByteString.EMPTY).build();
        SignBlobResponse response = iamCredentialsClient.signBlob(request);
    }
}
Also used : SignBlobRequest(com.google.cloud.iam.credentials.v1.SignBlobRequest) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) ByteString(com.google.protobuf.ByteString) SignBlobResponse(com.google.cloud.iam.credentials.v1.SignBlobResponse)

Example 19 with IamCredentialsClient

use of com.google.cloud.iam.credentials.v1.IamCredentialsClient in project gapic-generator-java by googleapis.

the class AsyncSignJwt method asyncSignJwt.

public static void asyncSignJwt() throws Exception {
    // It may require modifications to work in your environment.
    try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
        SignJwtRequest request = SignJwtRequest.newBuilder().setName(ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]").toString()).addAllDelegates(new ArrayList<String>()).setPayload("payload-786701938").build();
        ApiFuture<SignJwtResponse> future = iamCredentialsClient.signJwtCallable().futureCall(request);
        // Do something.
        SignJwtResponse response = future.get();
    }
}
Also used : SignJwtResponse(com.google.cloud.iam.credentials.v1.SignJwtResponse) IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) SignJwtRequest(com.google.cloud.iam.credentials.v1.SignJwtRequest)

Example 20 with IamCredentialsClient

use of com.google.cloud.iam.credentials.v1.IamCredentialsClient in project gapic-generator-java by googleapis.

the class SyncCreateSetCredentialsProvider method syncCreateSetCredentialsProvider.

public static void syncCreateSetCredentialsProvider() throws Exception {
    // This snippet has been automatically generated for illustrative purposes only.
    // It may require modifications to work in your environment.
    IamCredentialsSettings iamCredentialsSettings = IamCredentialsSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)).build();
    IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create(iamCredentialsSettings);
}
Also used : IamCredentialsClient(com.google.cloud.iam.credentials.v1.IamCredentialsClient) IamCredentialsSettings(com.google.cloud.iam.credentials.v1.IamCredentialsSettings)

Aggregations

IamCredentialsClient (com.google.cloud.iam.credentials.v1.IamCredentialsClient)21 ArrayList (java.util.ArrayList)11 ServiceAccountName (com.google.cloud.iam.credentials.v1.ServiceAccountName)5 SignJwtResponse (com.google.cloud.iam.credentials.v1.SignJwtResponse)5 GenerateIdTokenResponse (com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse)4 SignBlobResponse (com.google.cloud.iam.credentials.v1.SignBlobResponse)4 ByteString (com.google.protobuf.ByteString)4 GenerateAccessTokenResponse (com.google.cloud.iam.credentials.v1.GenerateAccessTokenResponse)3 IamCredentialsSettings (com.google.cloud.iam.credentials.v1.IamCredentialsSettings)3 HttpTransport (com.google.api.client.http.HttpTransport)2 GenerateIdTokenRequest (com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest)2 SignBlobRequest (com.google.cloud.iam.credentials.v1.SignBlobRequest)2 SignJwtRequest (com.google.cloud.iam.credentials.v1.SignJwtRequest)2 Duration (com.google.protobuf.Duration)2 IOException (java.io.IOException)2 RetryerBuilder (com.github.rholder.retry.RetryerBuilder)1 GoogleCredential (com.google.api.client.googleapis.auth.oauth2.GoogleCredential)1 GoogleNetHttpTransport (com.google.api.client.googleapis.javanet.GoogleNetHttpTransport)1 ApacheHttpTransport (com.google.api.client.http.apache.ApacheHttpTransport)1 JsonFactory (com.google.api.client.json.JsonFactory)1