All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.identity.AzureCliCredential Maven / Gradle / Ivy

There is a newer version: 1.14.2
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.identity;

import com.azure.identity.implementation.IdentityClient;
import com.azure.identity.implementation.IdentityClientBuilder;
import com.azure.identity.implementation.IdentityClientOptions;

import reactor.core.publisher.Mono;

import com.azure.core.annotation.Immutable;
import com.azure.core.credential.AccessToken;
import com.azure.core.credential.TokenCredential;
import com.azure.core.credential.TokenRequestContext;

/**
 * A credential provider that provides token credentials based on Azure CLI
 * command.
 */
@Immutable
public class AzureCliCredential implements TokenCredential {
    private final IdentityClient identityClient;

    /**
     * Creates an AzureCliSecretCredential with default identity client options.
     * @param identityClientOptions the options to configure the identity client
     */
    AzureCliCredential(IdentityClientOptions identityClientOptions) {
        identityClient = new IdentityClientBuilder().identityClientOptions(identityClientOptions).build();
    }

    @Override
    public Mono getToken(TokenRequestContext request) {
        return identityClient.authenticateWithAzureCli(request);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy