How to get existing user credential in browsers for Xamarin.Andriod WebView custom browser?

Yongqing Huang 241 Reputation points
2022-01-18T22:26:25.963+00:00

Hi,

I'm developing a custom browser using Xamarin.Andriod WebView.

There is a problem: In my custom browser, there is nothing for the existing user credential. The user needs to login again with username and password.

Is there a way to share / get /import the existing user credentials stored by the browsers (Chrome, Firefox..)?

Thanks in advance!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,491 Reputation points Microsoft Vendor
    2022-01-19T06:08:10.85+00:00

    Hello Yongqing,​

    Welcome to our Microsoft Q&A platform!

    There is a problem: In my custom browser, there is nothing for the existing user credential. The user needs to login again with username and password.

    You can create a custom renderer for your WebView. Then enable javascript And Dom Storage. This helps you to remember login details in webview app like following code.

       [assembly: ExportRenderer(typeof(Xamarin.Forms.WebView), typeof(MyWebviewCustomRenderer))]  
       namespace App7.Droid  
       {  
           internal class MyWebviewCustomRenderer : WebViewRenderer  
           {  
               public MyWebviewCustomRenderer(Context context) : base(context)  
               {  
               }  
         
               protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)  
               {  
                   base.OnElementChanged(e);  
         
                    
                   if (e.NewElement != null)  
                   {  
                       Control.Settings.JavaScriptEnabled = true ;   
                       Control.Settings.DomStorageEnabled = true ;  
                       Control.Settings.SavePassword = true;  
                       
                   }  
               }  
           }  
       }  
    

    Is there a way to share / get /import the existing user credentials stored by the browsers (Chrome, Firefox..)?

    No. Android app cannot access other application's credentials

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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