Hack Forums
[C#] Proxy : UserName/Password in Gecko 29 [C#] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Proxy : UserName/Password in Gecko 29 [C#] (/showthread.php?tid=4552728)



Proxy : UserName/Password in Gecko 29 [C#] - LakiLova - Nov 24, 2014

Hi, I want codes source to enter my username and password in this code

Code
Gecko.GeckoPreferences.User["network.proxy.userName"] = "username";
Gecko.GeckoPreferences.User["network.proxy.password"] = "password";

I have tried with this code but did not work

Code
public nsICancelable AsyncPromptAuth(nsIChannel aChannel, nsIAuthPromptCallback aCallback, nsISupports aContext, uint level, nsIAuthInformation authInfo)
{
    string userName = nsString.Get(authInfo.GetUsernameAttribute);
    string password = nsString.Get(authInfo.GetPasswordAttribute);

    string realm = nsString.Get(authInfo.GetRealmAttribute);

    if (PromptUsernameAndPassword(null, "Server Authentication", "The server '" + realm + "' requires a user name and password.", ref userName, ref password))
     {
      nsString.Set(authInfo.SetUsernameAttribute, userName);
      nsString.Set(authInfo.SetPasswordAttribute, password);
      aCallback.OnAuthAvailable(aContext, authInfo);
    }
    else
    {
      aCallback.OnAuthCancelled(aContext, true);
    }
    Cancelable cancel = new Cancelable();
    return cancel;
}

public class Cancelable : nsICancelable
{
    public int Reason { set; get; }
    public void Cancel(int aReason)
    {
      Reason = aReason;
    }
}


UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP UP


* - BerndMeier - Jan 28, 2016

got the same problem, anybody can help?