Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add device code print to console functionality #15332

Merged
merged 16 commits into from
Sep 28, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@
<suppress checks="MethodName|MemberName|VisibilityModifier|TypeName"
files="com.azure.identity.implementation.WindowsCredentialApi.java"/>

<!-- Need to write to stdout as the default SDK behavior here.-->
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck"
files="com.azure.identity.DeviceCodeCredentialBuilder.java"/>


<!-- Use the logger in a Utility static method. -->
<suppress checks="com.azure.tools.checkstyle.checks.GoodLoggingCheck" files="com.azure.ai.formrecognizer.Transforms.java" />
<suppress checks="com\.azure\.tools\.checkstyle\.checks\.(ThrowFromClientLoggerCheck|GoodLoggingCheck)" files="com.azure.ai.formrecognizer.training.models.CopyAuthorization" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
* @see DeviceCodeCredential
*/
public class DeviceCodeCredentialBuilder extends AadCredentialBuilderBase<DeviceCodeCredentialBuilder> {
private Consumer<DeviceCodeInfo> challengeConsumer;
private Consumer<DeviceCodeInfo> challengeConsumer =
deviceCodeInfo -> System.out.println(deviceCodeInfo.getMessage());

private boolean automaticAuthentication = true;

/**
* Sets the consumer to meet the device code challenge.
* Sets the consumer to meet the device code challenge. If not specified a default consumer is used which prints
* the device code info message to stdout.
*
* @param challengeConsumer A method allowing the user to meet the device code challenge.
* @return the InteractiveBrowserCredentialBuilder itself
Expand Down