Access Request: The browser pop-up window needs to enter a user name and password when http://192.168.2.113:8080/geoserver/rest/workspaces
, and if you do not enter or enter an error, the browser returns
You can see the details of the request here in Firefox's web monitoring,
The server returns a 401 unauthozied to the client and adds information to the response header "Www-authenticate".
When we enter the correct username and password, the server returns correctly. You can see the request information at this time:
This is the browser will send our user name and password after Base64 encoding, sent to the server.
This authentication method is HTTP Basic authentication, the process is:
1, the browser sends a GET request to the server, the server checks whether it contains the request header authorization information, if not, return the response code 401 and add the response header
2, the browser gets the response code automatically popup box lets the user enter the user name and the password, the browser base64 the user name and the password to encode (user name: password), sets the request header authorization, continues to visit
Method One: Increase the request parameters
Method Two: Use class authenticator
Step1 Creating class Inheritance Authenticator
Step2 before acquiring network resources, set the
3, the browser gets authorization request header information, verification success.
******************** himself wrote a service that required Basic authentication ************************************************************* ****************************
Other authentication methods of ********************************************http **************************************
In addition to this approach, there are three other ways of certifying
"HTTP authentication method"--basic authentication