Null reference on iOS AcquireTokenAsync(Scopes, UIParent)
See original GitHub issuename: Bug report about: Create a report to help us improve
Which Version of MSAL are you using ? MSAL 2.2.1-preview AND MSAL 2.3.1
Which platform has the issue? xamarin iOS
What authentication flow has the issue?
- Mobile
- [X ] Xamarin.iOS
What is the identity provider ?
- Azure AD
- [ X] Azure AD B2C
If B2C, what social identity did you use? Microsoft Account
Repro
result = await _pca.AcquireTokenAsync(AuthConstants.Scopes, _uiParent);
Expected behavior After a login on the webview I should be navigated back to the application and my token should be stored.
Actual behavior After the webview is closed the application is exitting with an null reference exception.
Additional context/ Logs / Screenshots
at Foundation.NSString…ctor (System.String str) [0x00009] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/Foundation/NSString.cs:139
at Foundation.NSData.FromString (System.String s, Foundation.NSStringEncoding encoding) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/Foundation/NSData.cs:208
at Foundation.NSData.op_Implicit (System.String s) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/Foundation/NSData.cs:214
at Microsoft.Identity.Core.iOSTokenCacheAccessor.CreateRecord (System.String account, System.String service, System.String generic, System.Int32 type, System.String value) [0x00014] in <420cc22f37f340a0a560df4a374dbe4a>:0
at Microsoft.Identity.Core.iOSTokenCacheAccessor.Save (System.String account, System.String service, System.String generic, System.Int32 type, System.String value) [0x00000] in <420cc22f37f340a0a560df4a374dbe4a>:0
at Microsoft.Identity.Core.iOSTokenCacheAccessor.SaveAccount (Microsoft.Identity.Core.Cache.MsalAccountCacheItem item) [0x00033] in <420cc22f37f340a0a560df4a374dbe4a>:0
at Microsoft.Identity.Core.Telemetry.TelemetryTokenCacheAccessor.SaveAccount (Microsoft.Identity.Core.Cache.MsalAccountCacheItem item) [0x00000] in <420cc22f37f340a0a560df4a374dbe4a>:0
at Microsoft.Identity.Core.Telemetry.TelemetryTokenCacheAccessor.SaveAccount (Microsoft.Identity.Core.Cache.MsalAccountCacheItem item, Microsoft.Identity.Core.RequestContext requestContext) [0x0001f] in <420cc22f37f340a0a560df4a374dbe4a>:0
at Microsoft.Identity.Client.TokenCache.SaveAccessAndRefreshToken (Microsoft.Identity.Client.Internal.Requests.AuthenticationRequestParameters requestParams, Microsoft.Identity.Core.OAuth2.MsalTokenResponse response) [0x00178] in <420cc22f37f340a0a560df4a374dbe4a>:0
at Microsoft.Identity.Client.Internal.Requests.RequestBase.CacheTokenResponseAndCreateAuthenticationResult (Microsoft.Identity.Core.OAuth2.MsalTokenResponse msalTokenResponse) [0x00181] in <420cc22f37f340a0a560df4a374dbe4a>:0
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest+<ExecuteAsync>d__9.MoveNext () [0x00168] in <420cc22f37f340a0a560df4a374dbe4a>:0
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 at Microsoft.Identity.Client.Internal.Requests.RequestBase+<RunAsync>d__18.MoveNext () [0x0016b] in <420cc22f37f340a0a560df4a374dbe4a>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at Microsoft.Identity.Client.PublicClientApplication+<AcquireTokenForLoginHintCommonAsync>d__23.MoveNext () [0x00106] in <420cc22f37f340a0a560df4a374dbe4a>:0
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 at Microsoft.Identity.Client.PublicClientApplication+<AcquireTokenAsync>d__15.MoveNext () [0x0009b] in <420cc22f37f340a0a560df4a374dbe4a>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter
1[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
at MyAppMobile.Services.AuthenticationService+<GetAccessToken>d__5.MoveNext () [0x001ee] in /Users/vcs12345/Documents/GIT/MyApp-Mobile/MyAppMobile/MyAppMobile/Services/AuthenticationService.cs:64
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
at MyAppMobile.ViewModels.LoginViewModel+<StartLoginProcess>d__11.MoveNext () [0x0005f] in /Users/vcs12345/Documents/GIT/MyApp-Mobile/MyAppMobile/MyAppMobile/ViewModels/LoginViewModel.cs:71
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/Foundation/NSAction.cs:178
— End of stack trace from previous location where exception was thrown —
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.0.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at MyAppMobile.iOS.Application.Main (System.String[] args) [0x00001] in /Users/vcs12345/Documents/GIT/MyApp-Mobile/MyAppMobile/MyAppMobile.iOS/Main.cs:17
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (4 by maintainers)
Top GitHub Comments
Yes, adding the User’s Object ID to the claim resolved my issue. Issue can be closed.
@Bloodyairtimer did your issue get resolved?