Date parsing issue in MSIToken [BUG]
See original GitHub issueDescribe the bug
Azure App Service Environment MSI endpoint is returning a JWT token with an expires_on with “AM” in it. “12/19/2019 5:03:41 AM +00:00”
parseDateToEpochSeconds() in MSIToken is parsing with a fixed pattern of “MM/dd/yyyy HH:mm:ss XXX” which will not parse with the expires_on coming from the MSI endpoint.
Exception or Stack Trace
Suppressed: com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of com.azure.identity.implementation.MSIToken
, problem: Unable to parse date time 12/19/2019 5:03:41 AM +00:00
at [Source: (String)“{“access_token”:”…"[truncated 1060 chars]; line: 1, column: 1427]
at com.fasterxml.jackson.databind.exc.ValueInstantiationException.from(ValueInstantiationException.java:47)
at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1732)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.wrapAsJsonMappingException(StdValueInstantiator.java:491)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.rewrapCtorProblem(StdValueInstantiator.java:514)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromObjectWith(StdValueInstantiator.java:285)
at com.fasterxml.jackson.databind.deser.ValueInstantiator.createFromObjectWith(ValueInstantiator.java:229)
at com.fasterxml.jackson.databind.deser.impl.PropertyBasedCreator.build(PropertyBasedCreator.java:198)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:422)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1287)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3205)
at com.azure.core.util.serializer.JacksonAdapter.deserialize(JacksonAdapter.java:174)
at com.azure.identity.implementation.IdentityClient.authenticateToManagedIdentityEndpoint(IdentityClient.java:350)
at com.azure.identity.AppServiceMsiCredential.authenticate(AppServiceMsiCredential.java:53)
at com.azure.identity.ManagedIdentityCredential.getToken(ManagedIdentityCredential.java:57)
at com.azure.identity.ChainedTokenCredential.lambda$getToken$1(ChainedTokenCredential.java:40)
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:378)
… 60 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unable to parse date time 12/19/2019 5:03:41 AM +00:00
at com.azure.identity.implementation.MSIToken.parseDateToEpochSeconds(MSIToken.java:83)
at com.azure.identity.implementation.MSIToken.<init>(MSIToken.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.fasterxml.jackson.databind.introspect.AnnotatedConstructor.call(AnnotatedConstructor.java:124)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromObjectWith(StdValueInstantiator.java:283)
… 74 common frames omitted
To Reproduce Use DefaultAzureCredentialBuilder to build credentials in an App Service Environment. The impacted one is in US East, so the ASE’s locale may have something to do with this issue.
Setup (please complete the following information):
- Version:
<dependency> <groupId>com.azure</groupId> <artifactId>azure-identity</artifactId> <version>1.0.1</version> </dependency>
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (4 by maintainers)
The problem seems to have started again. Using 1.1.0-beta.3
@Luyunmt
using the version 1.1.0-beta.6, the problem still seems to be there:
Cannot construct instance of
com.azure.identity.implementation.MSIToken
, problem: Unable to parse date time 7/21/2020 12:54:17 PM +00:00I am using a Windows AppService