18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

401 Authentication Required

dkellydkelly Members
edited November -1 in Sahi - Open Source
When I try to hit my web site a message comes up that says:

Scheme: negotiate | Realm: null
401 Authentication Required
Generated by Sahi for 401 response
Username <field>
Password <field>
Authenticate <button>

How do I get past this?

Comments

  • narayannarayan Administrators
    Hi dkelly,

    You need to enter the username password for the website. If, without Sahi, you do not explicitly specify it, most probably your windows login credentials were being used.

    Try
    windows_username and password
    or
    windows_domain\windows_username and password

    Note the backslash between domain and username. Forward slash will not work. Eg.
    MYDOMAIN\dkelly is correct
    MYDOMAIN/dkelly is NOT correct

    Regards,
    Narayan
  • dkellydkelly Members
    Yes, the windows_domain\username and password was the first thing I tried.

    I get the following in the console:
    Apr 6, 2010 1:10:17 PM net.sf.sahi.RemoteRequestProcessor process401
    INFO: scheme=negotiate; realm=null

    Is there some other authentication or certificate I should make sure I have?

    OR
    Is there some way to authenticate my domain\username when I start up sahi?
  • dkellydkelly Members
    Here is the full message from the console after entering my domain\username and password
    >>> Credentials added: negotiate KBHC0\dkelly
    Apr 6, 2010 1:36:09 PM net.sf.sahi.RemoteRequestProcessor process401
    INFO: >>> Negotiate
    Apr 6, 2010 1:36:09 PM net.sf.sahi.RemoteRequestProcessor process401
    INFO: scheme=negotiate; realm=null
  • dkellydkelly Members
    I suspect that either the 401 authentication in Sahi doesn't work OR I need some sort of certificate. How can I tell wha the problem is?
  • beesmanbeesman Members
    hi dkelly
    Have you solved the problem? i got the same error ,could you tell me ?
  • dkellydkelly Members
    No. In fact, I have put Sahi on hold (i.e. not using it) until this is resolved.
  • narayannarayan Administrators
    Hi dkelly,

    Specifying the username and password is all it should take to get 401 auth working.
    Could you please post the information you see on Sahi Controller's info tab? Let us check if the environment etc. are fine.

    Regards,
    Narayan
  • dkellydkelly Members
    I go to the web site then CTRL-ALT-DblClick on the page and I don't get the Sahi Controller as usual. Instead, I get the 401 Authentication Required message:

    Scheme: negotiate | Realm: null
    401 Authentication Required
    Generated by Sahi for 401 response

    I type in Username KBHC0\dkelly and password then click on Authenticate. Then I get a message that says "to display the webpage again, Internet Explorer needs to resend the information you've previously submitted". Then it displays the authentication prompt all over again. This repeats every time I re-enter username and password. The Controller never opened.

    The cmd window shows the following:
    Jul 23, 2010 8:32:54 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: >>> Negotiate
    Jul 23, 2010 8:32:54 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: scheme=negotiate; realm=null
    >>> Credentials added: negotiate KBHC0\dkelly
    Jul 23, 2010 8:33:34 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: >>> Negotiate
    Jul 23, 2010 8:33:34 AM net.sf.sahi.RemoteRequestProcessor process401
    INFO: scheme=negotiate; realm=null
  • narayannarayan Administrators
    Hi dkelly,

    Can you use the latest build of Sahi and check? There have been a few bug fixes related to spaces at the end of realms, null realms etc.

    Regards,
    Narayan
  • beesmanbeesman Members
    edited August 2010
    Sahi

    Version : V3
    Build : 2010-06-11
    Browser

    UserAgent : Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.5; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Name : Microsoft Internet Explorer
    Version : 4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.5; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Native XmlHTTPRequest : true
    Is Java enabled : true
    Is cookie enabled : true
    Operating System

    Name : Windows XP
    Version : 5.1
    Architecture : x86
    Is process list available : true
    Java

    Java Installed Directory : C:\Program Files\Java\jre6
    JRE Version : 1.6.0_20
    Is keytool available : true
    import java.rmi.RemoteException;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.sql.DataSource;
    import javax.xml.rpc.ServiceException;
    
    import org.apache.commons.codec.binary.Base64;
    
    public final class AuthDemo extends HttpServlet {
        
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        }
        
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException
        {
                doPost(req, resp);
        }
    
        public void  doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("windows-31j");
            response.setContentType("text/html; charset=windows-31j");
            String auth = request.getHeader("Authorization");
            if (auth == null)
            {
              response.setStatus(401); 
              response.setHeader("Cache-Control","no-store"); 
              response.setDateHeader("Expires",0); 
              response.setHeader("WWW-authenticate","Basic Realm=\"AuthDemo Server\""); 
              
            } else {
                response.getWriter().print("Authorization :" + request.getHeader("Authorization"));
            }
    
            String encoded = null;
            String decoded = null;
    
             String userName = "";
             String pass = "";
            
            String header = request.getHeader("Authorization");
               if (header != null) {
                   encoded = header.substring(header.indexOf(" ") + 1);
                   decoded = new String(Base64.decodeBase64(encoded.getBytes()));
                   String[]  admin = decoded.split(":");
                   
                    if(admin.length == 2){
                        userName = admin[0];
                        pass = admin[1];
                    }
              }
    
            
            request.getRequestDispatcher("/authDemo.jsp").forward(request, response);
        }
        
    }
    

    hi narayan
    could you help me?
    It not works

    I set breakpoint in first line of doGet() and doPost() , never executed.
    if i shutdown sahi , it will be executed
  • up
  • Thanks narayan 10#
  • Anyone got answer to this , even i am facing the same problem .

    I am using the latest version of SAHI...

    Anyone, Please help me if you have an answer to it.....
  • Hi Neha Auchar,

    Plese create a new forum post.

    Let me know what exactly you are trying to do what is the error message you are getting?

    Regards
    Sumitra
Sign In or Register to comment.