com.azure.identity.credential.DeviceCodeCredentialBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-identity Show documentation
Show all versions of azure-identity Show documentation
This module contains client library for Microsoft Azure Identity.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.identity.credential;
import com.azure.identity.DeviceCodeChallenge;
import com.azure.identity.implementation.util.ValidationUtil;
import java.util.HashMap;
import java.util.function.Consumer;
/**
* Fluent credential builder for instantiating a {@link DeviceCodeCredential}.
*
* @see DeviceCodeCredential
*/
public class DeviceCodeCredentialBuilder extends AadCredentialBuilderBase {
private Consumer deviceCodeChallengeConsumer;
/**
* Sets the port for the local HTTP server, for which {@code http://localhost:{port}} must be
* registered as a valid reply URL on the application.
*
* @param deviceCodeChallengeConsumer a method allowing the user to meet the device code challenge
* @return the InteractiveBrowserCredentialBuilder itself
*/
public DeviceCodeCredentialBuilder deviceCodeChallengeConsumer(
Consumer deviceCodeChallengeConsumer) {
this.deviceCodeChallengeConsumer = deviceCodeChallengeConsumer;
return this;
}
/**
* @return a {@link DeviceCodeCredential} with the current configurations.
*/
public DeviceCodeCredential build() {
ValidationUtil.validate(getClass().getSimpleName(), new HashMap() {{
put("clientId", clientId);
put("deviceCodeChallengeConsumer", deviceCodeChallengeConsumer);
}});
return new DeviceCodeCredential(clientId, tenantId, deviceCodeChallengeConsumer, identityClientOptions);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy