Search in sources :

Example 1 with GenerateIdTokenResponse

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

the class SyncGenerateIdToken method syncGenerateIdToken.

public static void syncGenerateIdToken() 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();
        GenerateIdTokenResponse response = iamCredentialsClient.generateIdToken(request);
    }
}
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 2 with GenerateIdTokenResponse

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

the class SyncGenerateIdTokenServiceaccountnameListstringStringBoolean method syncGenerateIdTokenServiceaccountnameListstringStringBoolean.

public static void syncGenerateIdTokenServiceaccountnameListstringStringBoolean() throws Exception {
    // It may require modifications to work in your environment.
    try (IamCredentialsClient iamCredentialsClient = IamCredentialsClient.create()) {
        ServiceAccountName name = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
        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) ServiceAccountName(com.google.cloud.iam.credentials.v1.ServiceAccountName) GenerateIdTokenResponse(com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse)

Example 3 with GenerateIdTokenResponse

use of com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse 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 4 with GenerateIdTokenResponse

use of com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse 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)

Aggregations

GenerateIdTokenResponse (com.google.cloud.iam.credentials.v1.GenerateIdTokenResponse)4 IamCredentialsClient (com.google.cloud.iam.credentials.v1.IamCredentialsClient)4 ArrayList (java.util.ArrayList)4 GenerateIdTokenRequest (com.google.cloud.iam.credentials.v1.GenerateIdTokenRequest)2 ServiceAccountName (com.google.cloud.iam.credentials.v1.ServiceAccountName)1