System.InvalidOperationException: On Xamarin.Android, you have to specify the current Activity from which the browser pop-up will be displayed using the WithParentActivityOrWindow method.
See original GitHub issueOn executing this line authResult = await App.PCA.AcquireTokenInteractive(App.Scopes) .WithParentActivityOrWindow(App.ParentWindow) .ExecuteAsync();
It is throwing Exception:
05-22 14:32:40.165 E/mono (29592):
05-22 14:32:40.165 E/mono (29592): Unhandled Exception:
05-22 14:32:40.165 E/mono (29592): System.InvalidOperationException: On Xamarin.Android, you have to specify the current Activity from which the browser pop-up will be displayed using the WithParentActivityOrWindow method.
05-22 14:32:40.165 E/mono (29592): at Microsoft.Identity.Client.AcquireTokenInteractiveParameterBuilder.Validate () [0x00018] in <48941809037546559a7e7308bdd45147>:0
05-22 14:32:40.165 E/mono (29592): at Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder1[T].ValidateAndCalculateApiId () [0x00000] in <48941809037546559a7e7308bdd45147>:0 05-22 14:32:40.165 E/mono (29592): at Microsoft.Identity.Client.AbstractPublicClientAcquireTokenParameterBuilder
1[T].ExecuteAsync (System.Threading.CancellationToken cancellationToken) [0x00000] in <48941809037546559a7e7308bdd45147>:0
05-22 14:32:40.165 E/mono (29592): at Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder1[T].ExecuteAsync () [0x00006] in <48941809037546559a7e7308bdd45147>:0 05-22 14:32:40.165 E/mono (29592): at Variance.ViewModels.MainPageViewModel+<OnSignInSignOut>d__12.MoveNext () [0x00285] in C:\Mobility\test\Variation\App\Variance\Variance\ViewModels\MainPageViewModel.cs:78 05-22 14:32:40.165 E/mono (29592): --- End of stack trace from previous location where exception was thrown --- 05-22 14:32:40.165 E/mono (29592): at (wrapper dynamic-method) System.Object.24(intptr,intptr) 05-22 14:32:40.165 E/mono (29592): at (wrapper native-to-managed) System.Object.24(intptr,intptr) 05-22 14:32:40.172 E/mono-rt (29592): [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: On Xamarin.Android, you have to specify the current Activity from which the browser pop-up will be displayed using the WithParentActivityOrWindow method. 05-22 14:32:40.172 E/mono-rt (29592): at Microsoft.Identity.Client.AcquireTokenInteractiveParameterBuilder.Validate () [0x00018] in <48941809037546559a7e7308bdd45147>:0 05-22 14:32:40.172 E/mono-rt (29592): at Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder
1[T].ValidateAndCalculateApiId () [0x00000] in <48941809037546559a7e7308bdd45147>:0
05-22 14:32:40.172 E/mono-rt (29592): at Microsoft.Identity.Client.AbstractPublicClientAcquireTokenParameterBuilder1[T].ExecuteAsync (System.Threading.CancellationToken cancellationToken) [0x00000] in <48941809037546559a7e7308bdd45147>:0 05-22 14:32:40.172 E/mono-rt (29592): at Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder
1[T].ExecuteAsync () [0x00006] in <48941809037546559a7e7308bdd45147>:0
05-22 14:32:40.172 E/mono-rt (29592): at Variance.ViewModels.MainPageViewModel+<OnSignInSignOut>d__12.MoveNext () [0x00285] in C:\Mobility\test\Variation\App\Variance\Variance\ViewModels\MainPageViewModel.cs:78
05-22 14:32:40.172 E/mono-rt (29592): — End of stack trace from previous location where exception was thrown —
05-22 14:32:40.172 E/mono-rt (29592): at (wrapper dynamic-method) System.Object.24(intptr,intptr)
05-22 14:32:40.172 E/mono-rt (29592): at (wrapper native-to-managed) System.Object.24(intptr,intptr)
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (11 by maintainers)
Top GitHub Comments
@lorne-olo glad you got android sorted out. @aiwangmicrosoft Can you help make sure the docs/sample code are the same? thank you.
For iOS, do you have all the provisioning profile information set up? I think you have to have it connected to a Mac to get it to work and provision correctly.
Thanks for confirming, @robiharid. Closing. cc: @jennyf19