"HTTP authentication method"--basic authentication

Source: Internet
Author: User
Tags base64 http authentication response code

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.