Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.27k stars 1.95k forks source link

[BUG] Cannot persist `DeviceCodeCredential` in accordance with documentation #41018

Closed FelixZY closed 2 weeks ago

FelixZY commented 1 month ago

Describe the bug I'm following the documentation on token caching, specifically the section on persistent token caching. However, despite the presence of tokencache.bin, I'm still asked for credentials on every run.

Exception or Stack Trace N/A (though I've run into #28186 when attempting to use the DeviceCodeCredential in a SecretClient after the attached code. As there is no solution proposed for #28186, I'm not sure how to fix that (but let's address my current issue first)).

To Reproduce

Run the attached code snippet twice.

Code Snippet

This is my setup based on the documentation. I have inlined the relevant code sample from the documentation above the actual code (representing my understanding of the samples and how I've translated it to kotlin). Note that I'm using blocking functions rather than async intentionally. While the docs use an InteractiveBrowserCredential, DeviceCodeCredential is listed as supported under "Credentials supporting token caching".

Main.kt ```kotlin package com.example import com.azure.identity.* import java.io.FileInputStream import java.io.FileOutputStream fun main() { // String authRecordFilePath = "./tokencache.bin"; val authRecordFilePath = "./tokencache.bin" /* AuthenticationRecord authenticationRecord = AuthenticationRecord.deserialize(new FileInputStream(authRecordFilePath)); InteractiveBrowserCredential interactiveBrowserCredential = new InteractiveBrowserCredentialBuilder() .tokenCachePersistenceOptions(new TokenCachePersistenceOptions()) .authenticationRecord(authenticationRecord) .build(); */ val authenticationRecord: AuthenticationRecord? = runCatching { AuthenticationRecord.deserialize(FileInputStream(authRecordFilePath)) }.getOrNull() println("authenticationRecord is null: ${authenticationRecord == null}") val credential: DeviceCodeCredential = DeviceCodeCredentialBuilder() .tokenCachePersistenceOptions(TokenCachePersistenceOptions()) .authenticationRecord(authenticationRecord) .challengeConsumer { println(it.message) } .build() /* interactiveBrowserCredential.authenticate() .flatMap(authenticationRecord -> { try { return authenticationRecord.serializeAsync(new FileOutputStream(authRecordFilePath)); } catch (FileNotFoundException e) { return Mono.error(e); } }).subscribe(); */ credential.authenticate().block()?.let { authenticationRecord: AuthenticationRecord -> authenticationRecord.serialize(FileOutputStream(authRecordFilePath)) } println("Signed in!") } ```

Expected behavior Run 1

authenticationRecord is null: true
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code LNHTHTVVJ to authenticate.
Signed in!

Run 2

authenticationRecord is null: false
Signed in!

Actual behavior Run 1

authenticationRecord is null: true
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code LNHTHTVVJ to authenticate.
Signed in!

Run 2

authenticationRecord is null: false
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code LS3TR2HE5 to authenticate.
Signed in!

Setup (please complete the following information):

Additional context

DEBUG level logs for a second run ``` [main] DEBUG reactor.util.Loggers - Using Slf4j logging framework authenticationRecord is null: false [main] DEBUG com.azure.core.implementation.ReflectionUtils - Attempting to use java.lang.invoke package to handle reflection. [main] DEBUG com.azure.core.implementation.ReflectionUtils - Successfully used java.lang.invoke package to handle reflection. [main] DEBUG com.azure.core.implementation.util.Providers - Using com.azure.core.http.netty.NettyAsyncHttpClientProvider as the default com.azure.core.http.HttpClientProvider. [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 21 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.storeFence: available [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: unavailable: Reflective setAccessible(true) disabled [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable: class io.netty.util.internal.PlatformDependent0$7 cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @35047d03 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.(long, {int,long}): unavailable [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: /tmp (java.io.tmpdir) [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model) [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: -1 bytes [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1 [main] DEBUG io.netty.util.internal.CleanerJava9 - java.nio.ByteBuffer.cleaner(): available [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false [main] INFO com.azure.core.http.netty.implementation.NettyUtility - The following is Netty version information that was found on the classpath: 'io.netty:netty-common' version: 4.1.110.Final, 'io.netty:netty-handler' version: 4.1.110.Final, 'io.netty:netty-handler-proxy' version: 4.1.110.Final, 'io.netty:netty-buffer' version: 4.1.110.Final, 'io.netty:netty-codec' version: 4.1.110.Final, 'io.netty:netty-codec-http' version: 4.1.110.Final, 'io.netty:netty-codec-http2' version: 4.1.110.Final, 'io.netty:netty-transport-native-unix-common' version: 4.1.110.Final, 'io.netty:netty-transport-native-epoll' version: 4.1.110.Final, 'io.netty:netty-transport-native-kqueue' version: 4.1.110.Final. The version of azure-core-http-netty being used was built with Netty version 4.1.108.Final and Netty Tcnative version 2.0.65.Final. If your application runs without issue this message can be ignored, otherwise please align the Netty versions used in your application. For more information, see https://aka.ms/azsdk/java/dependency/troubleshoot. [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4 [main] DEBUG com.microsoft.aad.msal4jextensions.CrossProcessCacheFileLock - pid:102473 thread:1 acquiring file lock [main] DEBUG com.microsoft.aad.msal4jextensions.CrossProcessCacheFileLock - pid:102473 thread:1 acquired OK file lock [main] DEBUG com.microsoft.aad.msal4jextensions.CrossProcessCacheFileLock - pid:102473 thread:1 releasing lock [ForkJoinPool.commonPool-worker-1] DEBUG com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider - No cached instance metadata, will attempt instance discovery. [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.NetUtilInitializations - Loopback interface: lo (lo, 0:0:0:0:0:0:0:1%lo) [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.NetUtil - /proc/sys/net/core/somaxconn: 4096 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.workdir: /tmp (io.netty.tmpdir) [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.deleteLibAfterLoading: true [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.tryPatchShadedId: true [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.detectNativeLibraryDuplicates: true [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.handler.ssl.OpenSsl - Failed to load netty-tcnative; OpenSslEngine will be unavailable, unless the application has already loaded the symbols by some other means. See https://netty.io/wiki/forked-tomcat-native.html for more information. java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty_tcnative_linux_x86_64, netty_tcnative_linux_x86_64_fedora, netty_tcnative_x86_64, netty_tcnative] at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:114) at io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:682) at io.netty.handler.ssl.OpenSsl.(OpenSsl.java:108) at io.netty.handler.ssl.SslProvider.isAlpnSupported(SslProvider.java:53) at reactor.netty.http.Http2SslContextSpec.lambda$static$0(Http2SslContextSpec.java:170) at reactor.netty.tcp.AbstractProtocolSslContextSpec.configure(AbstractProtocolSslContextSpec.java:47) at reactor.netty.tcp.AbstractProtocolSslContextSpec.(AbstractProtocolSslContextSpec.java:39) at reactor.netty.http.Http2SslContextSpec.(Http2SslContextSpec.java:155) at reactor.netty.http.Http2SslContextSpec.forClient(Http2SslContextSpec.java:59) at reactor.netty.http.client.HttpClientSecure.(HttpClientSecure.java:58) at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:217) at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:58) at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:77) at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46) at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:276) at reactor.core.publisher.Mono.subscribe(Mono.java:4491) at reactor.core.publisher.Mono.block(Mono.java:1741) at com.azure.core.http.netty.NettyAsyncHttpClient.sendSync(NettyAsyncHttpClient.java:195) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:51) at com.azure.core.http.policy.HttpLoggingPolicy.processSync(HttpLoggingPolicy.java:175) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.implementation.http.policy.InstrumentationPolicy.processSync(InstrumentationPolicy.java:101) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.http.policy.RetryPolicy.attemptSync(RetryPolicy.java:211) at com.azure.core.http.policy.RetryPolicy.processSync(RetryPolicy.java:161) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.http.policy.AddHeadersPolicy.processSync(AddHeadersPolicy.java:66) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.http.policy.HttpPipelineSyncPolicy.processSync(HttpPipelineSyncPolicy.java:51) at com.azure.core.http.policy.UserAgentPolicy.processSync(UserAgentPolicy.java:174) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.http.HttpPipeline.sendSync(HttpPipeline.java:138) at com.azure.identity.implementation.HttpPipelineAdapter.send(HttpPipelineAdapter.java:67) at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequestWithRetries(HttpHelper.java:137) at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequest(HttpHelper.java:52) at com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider.executeRequest(AadInstanceDiscoveryProvider.java:299) at com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider.sendInstanceDiscoveryRequest(AadInstanceDiscoveryProvider.java:249) at com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider.doInstanceDiscoveryAndCache(AadInstanceDiscoveryProvider.java:360) at com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider.getMetadataEntry(AadInstanceDiscoveryProvider.java:107) at com.microsoft.aad.msal4j.AuthenticationResultSupplier.getAuthorityWithPrefNetworkHost(AuthenticationResultSupplier.java:39) at com.microsoft.aad.msal4j.AcquireTokenByDeviceCodeFlowSupplier.execute(AcquireTokenByDeviceCodeFlowSupplier.java:23) at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:69) at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:18) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_linux_x86_64 at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:239) at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:105) ... 50 more Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_linux_x86_64.so at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:186) ... 51 more Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_linux_x86_64 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916) at java.base/java.lang.System.loadLibrary(System.java:2059) at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:396) at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161) ... 51 more Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_linux_x86_64 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916) at java.base/java.lang.System.loadLibrary(System.java:2059) at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:430) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:422) at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:388) ... 52 more Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_linux_x86_64_fedora at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:239) at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:105) ... 50 more Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_linux_x86_64_fedora.so at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:186) ... 51 more Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_linux_x86_64_fedora in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916) at java.base/java.lang.System.loadLibrary(System.java:2059) at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:396) at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161) ... 51 more Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_linux_x86_64_fedora in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916) at java.base/java.lang.System.loadLibrary(System.java:2059) at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:430) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:422) at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:388) ... 52 more Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_x86_64 at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:239) at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:105) ... 50 more Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_x86_64.so at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:186) ... 51 more Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_x86_64 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916) at java.base/java.lang.System.loadLibrary(System.java:2059) at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:396) at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161) ... 51 more Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_x86_64 in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916) at java.base/java.lang.System.loadLibrary(System.java:2059) at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:430) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:422) at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:388) ... 52 more Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:239) at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:105) ... 50 more Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative.so at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:186) ... 51 more Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916) at java.base/java.lang.System.loadLibrary(System.java:2059) at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:396) at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161) ... 51 more Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2458) at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:916) at java.base/java.lang.System.loadLibrary(System.java:2059) at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:430) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:422) at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:388) ... 52 more [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.handler.ssl.OpenSsl - Initialize netty-tcnative using engine: 'default' [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.handler.ssl.OpenSsl - Failed to initialize netty-tcnative; OpenSslEngine will be unavailable. See https://netty.io/wiki/forked-tomcat-native.html for more information. java.lang.UnsatisfiedLinkError: 'int io.netty.internal.tcnative.Library.aprMajorVersion()' at io.netty.internal.tcnative.Library.aprMajorVersion(Native Method) at io.netty.internal.tcnative.Library.initialize(Library.java:191) at io.netty.handler.ssl.OpenSsl.initializeTcNative(OpenSsl.java:687) at io.netty.handler.ssl.OpenSsl.(OpenSsl.java:125) at io.netty.handler.ssl.SslProvider.isAlpnSupported(SslProvider.java:53) at reactor.netty.http.Http2SslContextSpec.lambda$static$0(Http2SslContextSpec.java:170) at reactor.netty.tcp.AbstractProtocolSslContextSpec.configure(AbstractProtocolSslContextSpec.java:47) at reactor.netty.tcp.AbstractProtocolSslContextSpec.(AbstractProtocolSslContextSpec.java:39) at reactor.netty.http.Http2SslContextSpec.(Http2SslContextSpec.java:155) at reactor.netty.http.Http2SslContextSpec.forClient(Http2SslContextSpec.java:59) at reactor.netty.http.client.HttpClientSecure.(HttpClientSecure.java:58) at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:217) at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:58) at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:77) at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46) at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:276) at reactor.core.publisher.Mono.subscribe(Mono.java:4491) at reactor.core.publisher.Mono.block(Mono.java:1741) at com.azure.core.http.netty.NettyAsyncHttpClient.sendSync(NettyAsyncHttpClient.java:195) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:51) at com.azure.core.http.policy.HttpLoggingPolicy.processSync(HttpLoggingPolicy.java:175) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.implementation.http.policy.InstrumentationPolicy.processSync(InstrumentationPolicy.java:101) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.http.policy.RetryPolicy.attemptSync(RetryPolicy.java:211) at com.azure.core.http.policy.RetryPolicy.processSync(RetryPolicy.java:161) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.http.policy.AddHeadersPolicy.processSync(AddHeadersPolicy.java:66) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.http.policy.HttpPipelineSyncPolicy.processSync(HttpPipelineSyncPolicy.java:51) at com.azure.core.http.policy.UserAgentPolicy.processSync(UserAgentPolicy.java:174) at com.azure.core.http.HttpPipelineNextSyncPolicy.processSync(HttpPipelineNextSyncPolicy.java:53) at com.azure.core.http.HttpPipeline.sendSync(HttpPipeline.java:138) at com.azure.identity.implementation.HttpPipelineAdapter.send(HttpPipelineAdapter.java:67) at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequestWithRetries(HttpHelper.java:137) at com.microsoft.aad.msal4j.HttpHelper.executeHttpRequest(HttpHelper.java:52) at com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider.executeRequest(AadInstanceDiscoveryProvider.java:299) at com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider.sendInstanceDiscoveryRequest(AadInstanceDiscoveryProvider.java:249) at com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider.doInstanceDiscoveryAndCache(AadInstanceDiscoveryProvider.java:360) at com.microsoft.aad.msal4j.AadInstanceDiscoveryProvider.getMetadataEntry(AadInstanceDiscoveryProvider.java:107) at com.microsoft.aad.msal4j.AuthenticationResultSupplier.getAuthorityWithPrefNetworkHost(AuthenticationResultSupplier.java:39) at com.microsoft.aad.msal4j.AcquireTokenByDeviceCodeFlowSupplier.execute(AcquireTokenByDeviceCodeFlowSupplier.java:23) at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:69) at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:18) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.handler.ssl.JdkSslContext - Default protocols (JDK): [TLSv1.3, TLSv1.2] [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.handler.ssl.JdkSslContext - Default cipher suites (JDK): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384] [ForkJoinPool.commonPool-worker-1] DEBUG reactor.netty.tcp.TcpResources - [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=16, workerCount=16} [ForkJoinPool.commonPool-worker-1] DEBUG reactor.netty.tcp.TcpResources - [http] resources will use the default ConnectionProvider: reactor.netty.resources.DefaultPooledConnectionProvider@10559274 [ForkJoinPool.commonPool-worker-1] DEBUG reactor.netty.resources.PooledConnectionProvider - Creating a new [http] client pool [PoolFactory{evictionInterval=PT0S, leasingStrategy=fifo, maxConnections=500, maxIdleTime=-1, maxLifeTime=-1, metricsEnabled=false, pendingAcquireMaxCount=1000, pendingAcquireTimeout=45000}] for [login.microsoftonline.com/:443] [ForkJoinPool.commonPool-worker-1] DEBUG reactor.netty.resources.DefaultLoopIOUring - Default io_uring support : false [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.internal.NativeLibraryLoader - Successfully loaded the library /tmp/libnetty_transport_native_epoll_x86_643294888604226287159.so [ForkJoinPool.commonPool-worker-1] DEBUG reactor.netty.resources.DefaultLoopEpoll - Default Epoll support : true [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 32 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.concurrent.GlobalEventExecutor - -Dio.netty.globalEventExecutor.quietPeriodSeconds: 1 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 102473 (auto-detected) [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: 00:41:0e:ff:fe:d0:a7:c7 (auto-detected) [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 32 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 32 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 9 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 4194304 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimIntervalMillis: 0 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: false [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0 [ForkJoinPool.commonPool-worker-1] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384 [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f] Created a new pooled channel, now: 0 active connections, 0 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.tcp.SslProvider - [43e6146f] SSL enabled using engine SSLEngine[hostname=login.microsoftonline.com, port=443, Session(1720110177232|SSL_NULL_WITH_NULL_NULL)] and SNI login.microsoftonline.com/:443 [reactor-http-epoll-1] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkAccessible: true [reactor-http-epoll-1] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkBounds: true [reactor-http-epoll-1] DEBUG io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@5173e454 [reactor-http-epoll-1] DEBUG reactor.netty.transport.TransportConfig - [43e6146f] Initialized pipeline DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.sslReader = reactor.netty.tcp.SslProvider$SslReadHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.transport.TransportConnector - [43e6146f] Connecting to [login.microsoftonline.com/20.190.181.5:443]. [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Registering pool release on close event for channel [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel connected, now: 1 active connections, 0 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 4096 [reactor-http-epoll-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8 [reactor-http-epoll-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.chunkSize: 32 [reactor-http-epoll-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.blocking: false [reactor-http-epoll-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.batchFastThreadLocalOnly: true [reactor-http-epoll-1] DEBUG io.netty.handler.ssl.SslHandler - [id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] HANDSHAKEN: protocol:TLSv1.3 cipher suite:TLS_AES_256_GCM_SHA384 [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}, [connected]) [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-1, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(GET{uri=null, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [configured]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientConnect - [43e6146f-1, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Handler is being applied: {uri=https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize, method=GET} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-1, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(GET{uri=/common/discovery/instance, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_prepared]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f-1, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Added decoder [azureSdkHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, azureSdkHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0] [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-1, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(GET{uri=/common/discovery/instance, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_sent]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-1, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received response (auto-read:false) : RESPONSE(decodeResult: success, version: HTTP/1.1) HTTP/1.1 200 OK Cache-Control: Content-Type: Strict-Transport-Security: X-Content-Type-Options: Access-Control-Allow-Origin: Access-Control-Allow-Methods: P3P: client-request-id: x-ms-request-id: x-ms-ests-server: x-ms-srs: X-XSS-Protection: Set-Cookie: Set-Cookie: Set-Cookie: Set-Cookie: Date: Content-Length: [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-1, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(GET{uri=/common/discovery/instance, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_received]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-1, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received last HTTP packet [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(GET{uri=/common/discovery/instance, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_completed]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Removed handler: azureSdkHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Non Removed handler: azureSdkHandler, context: null, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(GET{uri=/common/discovery/instance, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [disconnecting]) [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Releasing channel [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel cleaned, now: 0 active connections, 1 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.channel.FluxReceive - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] [terminated=true, cancelled=false, pending=1, error=null]: subscribing inbound receiver [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel acquired, now: 1 active connections, 0 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientConnect - [43e6146f-2, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Handler is being applied: {uri=https://login.microsoftonline.com/organizations/oauth2/v2.0/devicecode, method=POST} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-2, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/devicecode, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_prepared]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f-2, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Added decoder [azureSdkHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, azureSdkHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0] [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-2, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/devicecode, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_sent]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-2, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received response (auto-read:false) : RESPONSE(decodeResult: success, version: HTTP/1.1) HTTP/1.1 200 OK Cache-Control: Pragma: Content-Type: Expires: Strict-Transport-Security: X-Content-Type-Options: P3P: client-request-id: x-ms-request-id: x-ms-ests-server: x-ms-clitelem: x-ms-srs: X-XSS-Protection: Set-Cookie: Set-Cookie: Set-Cookie: Set-Cookie: Date: Content-Length: [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-2, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/devicecode, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_received]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-2, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received last HTTP packet [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/devicecode, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_completed]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Removed handler: azureSdkHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Non Removed handler: azureSdkHandler, context: null, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/devicecode, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [disconnecting]) [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Releasing channel [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel cleaned, now: 0 active connections, 1 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.channel.FluxReceive - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] [terminated=true, cancelled=false, pending=1, error=null]: subscribing inbound receiver [ForkJoinPool.commonPool-worker-1] DEBUG com.microsoft.aad.msal4j.TokenRequestExecutor - Sending token request to: https://login.microsoftonline.com/organizations/ [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel acquired, now: 1 active connections, 0 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientConnect - [43e6146f-3, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Handler is being applied: {uri=https://login.microsoftonline.com/organizations/oauth2/v2.0/token, method=POST} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-3, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_prepared]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f-3, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Added decoder [azureSdkHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, azureSdkHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0] [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-3, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_sent]) To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code GZTUADLLB to authenticate. [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-3, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received response (auto-read:false) : RESPONSE(decodeResult: success, version: HTTP/1.1) HTTP/1.1 400 Bad Request Cache-Control: Pragma: Content-Type: Expires: Strict-Transport-Security: X-Content-Type-Options: P3P: client-request-id: x-ms-request-id: x-ms-ests-server: x-ms-clitelem: x-ms-srs: X-XSS-Protection: Set-Cookie: Set-Cookie: Set-Cookie: Date: Content-Length: [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-3, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_received]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-3, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received last HTTP packet [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_completed]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Removed handler: azureSdkHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Non Removed handler: azureSdkHandler, context: null, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [disconnecting]) [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Releasing channel [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel cleaned, now: 0 active connections, 1 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.channel.FluxReceive - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] [terminated=true, cancelled=false, pending=1, error=null]: subscribing inbound receiver [ForkJoinPool.commonPool-worker-1] DEBUG com.microsoft.aad.msal4j.TokenRequestExecutor - Sending token request to: https://login.microsoftonline.com/organizations/ [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel acquired, now: 1 active connections, 0 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientConnect - [43e6146f-4, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Handler is being applied: {uri=https://login.microsoftonline.com/organizations/oauth2/v2.0/token, method=POST} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-4, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_prepared]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f-4, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Added decoder [azureSdkHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, azureSdkHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0] [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-4, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_sent]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-4, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received response (auto-read:false) : RESPONSE(decodeResult: success, version: HTTP/1.1) HTTP/1.1 400 Bad Request Cache-Control: Pragma: Content-Type: Expires: Strict-Transport-Security: X-Content-Type-Options: P3P: client-request-id: x-ms-request-id: x-ms-ests-server: x-ms-clitelem: x-ms-srs: X-XSS-Protection: Set-Cookie: Set-Cookie: Set-Cookie: Date: Content-Length: [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-4, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_received]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-4, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received last HTTP packet [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_completed]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Removed handler: azureSdkHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Non Removed handler: azureSdkHandler, context: null, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [disconnecting]) [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Releasing channel [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel cleaned, now: 0 active connections, 1 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.channel.FluxReceive - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] [terminated=true, cancelled=false, pending=1, error=null]: subscribing inbound receiver [ForkJoinPool.commonPool-worker-1] DEBUG com.microsoft.aad.msal4j.TokenRequestExecutor - Sending token request to: https://login.microsoftonline.com/organizations/ [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel acquired, now: 1 active connections, 0 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientConnect - [43e6146f-5, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Handler is being applied: {uri=https://login.microsoftonline.com/organizations/oauth2/v2.0/token, method=POST} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-5, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_prepared]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f-5, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Added decoder [azureSdkHandler] at the end of the user pipeline, full pipeline: [reactor.left.sslHandler, reactor.left.httpCodec, azureSdkHandler, reactor.right.reactiveBridge, DefaultChannelPipeline$TailContext#0] [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-5, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [request_sent]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-5, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received response (auto-read:false) : RESPONSE(decodeResult: success, version: HTTP/1.1) HTTP/1.1 200 OK Cache-Control: Pragma: Content-Type: Expires: Strict-Transport-Security: X-Content-Type-Options: P3P: client-request-id: x-ms-request-id: x-ms-ests-server: x-ms-clitelem: x-ms-srs: X-XSS-Protection: Set-Cookie: Set-Cookie: Set-Cookie: Date: Content-Length: [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f-5, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_received]) [reactor-http-epoll-1] DEBUG reactor.netty.http.client.HttpClientOperations - [43e6146f-5, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Received last HTTP packet [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [response_completed]) [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Removed handler: azureSdkHandler, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.ReactorNetty - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Non Removed handler: azureSdkHandler, context: null, pipeline: DefaultChannelPipeline{(reactor.left.sslHandler = io.netty.handler.ssl.SslHandler), (reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] onStateChange(POST{uri=/organizations/oauth2/v2.0/token, connection=PooledConnection{channel=[id: 0x43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443]}}, [disconnecting]) [reactor-http-epoll-1] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Releasing channel [reactor-http-epoll-1] DEBUG reactor.netty.resources.PooledConnectionProvider - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] Channel cleaned, now: 0 active connections, 1 inactive connections and 0 pending acquire requests. [reactor-http-epoll-1] DEBUG reactor.netty.channel.FluxReceive - [43e6146f, L:/:41002 - R:login.microsoftonline.com/20.190.181.5:443] [terminated=true, cancelled=false, pending=1, error=null]: subscribing inbound receiver [ForkJoinPool.commonPool-worker-1] DEBUG com.microsoft.aad.msal4jextensions.CrossProcessCacheFileLock - pid:102473 thread:44 acquiring file lock [ForkJoinPool.commonPool-worker-1] DEBUG com.microsoft.aad.msal4jextensions.CrossProcessCacheFileLock - pid:102473 thread:44 acquired OK file lock [ForkJoinPool.commonPool-worker-1] DEBUG com.microsoft.aad.msal4jextensions.CrossProcessCacheFileLock - pid:102473 thread:44 releasing lock [ForkJoinPool.commonPool-worker-1] DEBUG com.microsoft.aad.msal4j.PublicClientApplication - [Correlation ID: c90a5a48-9f56-44f6-9fc6-bb68a2072e15] Access Token and Refresh Token were returned Signed in! ```

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

joshfree commented 3 weeks ago

@billwert since you closed https://github.com/Azure/azure-sdk-for-java/issues/28186 can you please follow up with @FelixZY

billwert commented 3 weeks ago

Hello!

This is a doc bug which we'll fix. Calling authenticate unconditionally will always cause a challenge, as we don't know that you are wanting to authenticate with the same user.

Here's what I get from the below program: Run 1:

No auth record
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code <redacted> to authenticate.
Logged in!

Run 2:

Logged in!
     String authRecord = "authrecord.bin";
        AuthenticationRecord record = null;
        try {
            record = AuthenticationRecord.deserialize(new FileInputStream(authRecord));
        } catch (FileNotFoundException e) {
            System.out.println("No auth record");
        }
        DeviceCodeCredential cred = new DeviceCodeCredentialBuilder()
                .tokenCachePersistenceOptions(new TokenCachePersistenceOptions())
                .authenticationRecord(record)
                .clientId("clientId")
                .tenantId("tenantId")
                .challengeConsumer(challenge -> System.out.println(challenge.getMessage()))
                .build();
        TokenRequestContext ctx = new TokenRequestContext().addScopes("https://graph.microsoft.com/User.Read");
        if (record == null) {
            // Perform the authentication and save the record
            AuthenticationRecord newRecord = cred.authenticate(ctx).block();
            try {
                newRecord.serialize(new FileOutputStream(authRecord));
            } catch (FileNotFoundException e) {
                System.out.println("couldn't serialize" + e.getMessage());
            }
        }
        AccessToken token = cred.getTokenSync(ctx);
        if (token.getToken() != null) {
            System.out.println("Logged in!");
        }
FelixZY commented 3 weeks ago

Updated Kotlin snippet:

package com.example

import com.azure.core.credential.TokenRequestContext
import com.azure.identity.AuthenticationRecord
import com.azure.identity.DeviceCodeCredential
import com.azure.identity.DeviceCodeCredentialBuilder
import com.azure.identity.TokenCachePersistenceOptions
import java.io.FileInputStream
import java.io.FileOutputStream

fun main(args: Array<String>) {
    val authRecordFilePath = "./tokencache.bin"

    val authenticationRecord: AuthenticationRecord? =
        runCatching {
            AuthenticationRecord.deserialize(FileInputStream(authRecordFilePath))
        }.getOrNull()

    println("authenticationRecord is null: ${authenticationRecord == null}")

    val credential: DeviceCodeCredential = DeviceCodeCredentialBuilder()
        .tokenCachePersistenceOptions(TokenCachePersistenceOptions())
        .authenticationRecord(authenticationRecord)
        .clientId("<redacted>")
        .tenantId("<redacted>")
        .challengeConsumer {
            println(it.message)
        }
        .build()

    val context = TokenRequestContext().addScopes("https://graph.microsoft.com/.default")

    if (authenticationRecord == null) {
        credential.authenticate(context).block()?.let { authenticationRecord: AuthenticationRecord ->
            authenticationRecord.serialize(FileOutputStream(authRecordFilePath))
        }
    }

    if (credential.getTokenSync(context) == null) {
        error("Not signed in!")
    } else {
        println("Signed in!")
    }
}

Changes

Output:

Run 1

authenticationRecord is null: true
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code REDACTED to authenticate.
[ForkJoinPool.commonPool-worker-1] ERROR com.microsoft.aad.msal4jextensions.CrossProcessCacheFileLock - null
Signed in!

Run 2

authenticationRecord is null: false
[ForkJoinPool.commonPool-worker-1] ERROR com.microsoft.aad.msal4jextensions.CrossProcessCacheFileLock - null
Signed in!

@billwert As you can see, it seems I am now running into #28186 - any advice?

FelixZY commented 2 weeks ago

@billwert just want to make sure you didn't miss the remaining issue now that the primary issue is resolved (and this issue could suddenly be locked).