Essentials
Essentials copied to clipboard
Open uri with User and password
Description
Hi, I try open a URL with user and password in Browser.OpenAsync() and the internal method "Browser.EscapeUri" intercept and create a new URI before call native plataform method and remove userinfo from the URI.
Original URI: http://user:[email protected] New URI create by Browser.EscapeUri: http://www.example.com
Why method EscapeUri exists? Is possible remove him?
If is not possible remove EscapeUri, create a new method that not call him.
Steps to Reproduce
- Open URI with user and password with Browser.OpenAsync(...)
- Browser prompt again for user and password
Expected Behavior
Not change URI
Actual Behavior
Remove user and password from new generated URI
Basic Information
- Version with issue: All
- IDE: VS2022
- Platform Target Frameworks: All plataforms
Workaround
For now I call same internal method that Browser.OpenAsync run by reflection
var type = typeof(Xamarin.Essentials.Browser);
var method = type.GetMethod(
"PlatformOpenAsync",
BindingFlags.NonPublic
| BindingFlags.Public
| BindingFlags.Static
| BindingFlags.FlattenHierarchy)
?? throw new NotImplementedException(
"Método 'PlatformOpenAsync' não encontrado para a plataforma");
var task = (Task<bool>)method.Invoke(null, new[] { (object)uri, options });
await task;