question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] HoloLens 2 device code flow does not work

See original GitHub issue

Logs and Network traces Error setting value to 'TenantDiscoveryEndpoint' on 'Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryResponse'. at Microsoft.Identity.Json.Serialization.ExpressionValueProvider.SetValue (System.Object target, System.Object value) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Microsoft.Identity.Json.Serialization.JsonProperty property, Microsoft.Identity.Json.JsonConverter propertyConverter, Microsoft.Identity.Json.Serialization.JsonContainerContract containerContract, Microsoft.Identity.Json.Serialization.JsonProperty containerProperty, Microsoft.Identity.Json.JsonReader reader, System.Object target) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Microsoft.Identity.Json.JsonReader reader, Microsoft.Identity.Json.Serialization.JsonObjectContract contract, Microsoft.Identity.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.Serialization.JsonSerializerInternalReader.CreateObject (Microsoft.Identity.Json.JsonReader reader, System.Type objectType, Microsoft.Identity.Json.Serialization.JsonContract contract, Microsoft.Identity.Json.Serialization.JsonProperty member, Microsoft.Identity.Json.Serialization.JsonContainerContract containerContract, Microsoft.Identity.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Microsoft.Identity.Json.JsonReader reader, System.Type objectType, Microsoft.Identity.Json.Serialization.JsonContract contract, Microsoft.Identity.Json.Serialization.JsonProperty member, Microsoft.Identity.Json.Serialization.JsonContainerContract containerContract, Microsoft.Identity.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.Serialization.JsonSerializerInternalReader.Deserialize (Microsoft.Identity.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.JsonSerializer.DeserializeInternal (Microsoft.Identity.Json.JsonReader reader, System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Microsoft.Identity.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.JsonConvert.DeserializeObject[T] (System.String value, Microsoft.Identity.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Client.Utils.JsonHelper.DeserializeFromJson[T] (System.String json) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Client.OAuth2.OAuth2Client.CreateResponse[T] (Microsoft.Identity.Client.Http.HttpResponse response, Microsoft.Identity.Client.Internal.RequestContext requestContext) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Identity.Json.Linq.Extensions+<Convert>d__142[T,U].<>m__Finally1 () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000]`

Which Version of MSAL are you using ? 4.22, built from the current MSAL master branch.

Platform Unity 2019.4.0f1, UWP, IL2CPP, ARM for HoloLens 2

What authentication flow has the issue?

  • Desktop / Mobile
    • Interactive
    • Integrated Windows Auth
    • Username Password
    • Device code flow (browserless)
  • Web App
    • Authorization code
    • OBO
  • Daemon App
    • Service to Service calls

Other? - please describe;

Is this a new or existing app? We were using some version of MSAL v3, but application in production started having issues with authenticating private accounts. After long support session we learned that we should change a little our flow, this required update to MSAL v4. Unfortunately, while everything works fine in the editor, version deployed on the HoloLens does not.

Repro

I am attaching whole script that contains our logic for device code. Controller script only calls SignInWithDeviceFlow() method and this method fails on AcquireToken.

DeviceCodeAuthenticator.txt

Expected behavior Using AcquireTokenWithDeviceCode should give code to authenticate user.

Actual behavior Exception is being thrown and no code is given.

Possible Solution This issue appeared in MSAL v3 we were using previously and link.xml fixed it. In the new version of MSAL, this fix does not work. I have turned panic mode on and basically put all possible options in link.xml, still does not work. Here is the content:

<linker>    
<assembly fullname="Microsoft.Identity.Client" preserve="all"/>
	<assembly fullname="Microsoft.Identity" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Json" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Json.Serialization" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Json.JsonConvert" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Json.Serialization.JsonProperty " preserve="all"/>
	<assembly fullname="Microsoft.Identity.Json.Serialization.JsonSerializerInternalReader" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryResponse" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.Utils" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.Instance.Discovery" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.Utils.JsonHelper" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.OAuth2" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.OAuth2.OAuth2Client" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.Internal" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Json.Linq" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.Cache" preserve="all"/>
	<assembly fullname="Microsoft.Identity.Client.Cache.TokenCacheJsonSerializer" preserve="all"/>
</linker>

Additional context/ Logs / Screenshots I have tried to cheat Unity bytestripping, by pasting the library into the build directory and then deploying it to the HoloLens, but it changes nothing. I have tried using several versions of MSAL:

  • 4.7.1
  • 4.22 built from master branch
  • 4.22 downloaded from NuGet and then copied over to Unity (only ARM version)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
najadojocommented, Jan 15, 2021

I’ve found a work around for this issue. The clue was in Unity Issue Tracker - [IL2CPP] NotSupportedExceptions exception is thrown in build with Newtonsoft.Json plugin (unity3d.com).

I needed to add to link.xml:

<assembly fullname="System" preserve="all" />
<assembly fullname="System.Core" preserve="all" />

Additionally and what the Unity docs are inaccurate about is that this must be in the root Assets/link.xml. Lower or package link.xml inclusions don’t work.

1reaction
jmprieurcommented, Jan 26, 2021

Thanks for the update, @najadojo I’ve updated the wiki page.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Device Troubleshooting - HoloLens
Stay up to date on the most common solutions to HoloLens device issues and troubleshooting techniques.
Read more >
Microsoft Graph Auth on HoloLens–Device Code Flow - Pete D
This flow allows the auth to happen on a second device which may be more convenient if typing passwords or codes is required...
Read more >
Authenticate a HoloLens Application to the Azure AD
Don't worry about performance, it's extremely fast. Using the Microsoft Authentication Library (MSAL) for authentication with Device Code flow.
Read more >
Visual Studio failed deploy to HoloLens: Error DEP6957
I had this issue and solved it by installing USB Device Connectivity through the individual components section of the visual studio ...
Read more >
draft-ietf-oauth-device-flow-15
(B) The authorization server issues a device code, an end-user code, and provides the end-user verification URI. (C) The client instructs the end...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found