SSO working for other SSO enabled portals but not working for PowerApps within Android WebView

Sagar S 21 Reputation points
2021-08-05T10:50:34.927+00:00

Hi Team,

I am working on an app built using Xamarin Forms (Android), logging in to app using MSAL and once I launch any SSO enabled portal within the WebView control the SSO works fine and it does not ask for re-authentication, however when I launch a PowerApps web portal it gives me an error - "A silent sign-in request was sent but no user is signed in. The cookies used to represent the user's session were not sent in the request to Azure AD. This can happen if third-party cookies are disabled"

It works for other SSO enabled portals but it gives me an error like above when trying to open any PowerApps web portal with in the WebView on Android.

Please note that, this works fine on iOS platform.

Could anyone, please guide me on this?

Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,326 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,629 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 72,251 Reputation points Microsoft Vendor
    2021-08-06T06:16:36.153+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Based on your description and error, please enable the SetAcceptThirdPartyCookies for your webview in custom renderer.

    https://developer.android.com/reference/android/webkit/CookieManager#acceptThirdPartyCookies(android.webkit.WebView)

       [assembly: ExportRenderer(typeof(Xamarin.Forms.WebView), typeof(HybridWebViewRenderer))]  
       namespace App117.Droid  
       {  
           class HybridWebViewRenderer : WebViewRenderer  
           {  
               public HybridWebViewRenderer(Context context) : base(context)  
               {  
               }  
               protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)  
               {  
                   base.OnElementChanged(e);  
         
                   var webView=Control as Android.Webkit.WebView;  
         
                   webView.Settings.JavaScriptEnabled = true;  
         
                   webView.Settings.SaveFormData = true;  
                   webView.Settings.SetAppCacheEnabled(true);  
                   
                   CookieManager cookieManager = CookieManager.Instance;  
                   cookieManager.SetAcceptCookie(true);  
                   CookieManager.Instance.SetAcceptThirdPartyCookies(webView, true);  
                   webView.SetWebViewClient(new MyWebviewClient());  
               }  
           }  
         
           internal class MyWebviewClient : WebViewClient  
           {  
               public override bool ShouldOverrideUrlLoading(Android.Webkit.WebView view, string url)  
               {  
                   view.LoadUrl(url);  
                   return true;  
         
               }  
           }  
       }  
    

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful