Ethernet token sending interface
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
cm = new (schemeRegistry);
cm.setMaxTotal(200);
cm.setDefaultMaxPerRoute(2);
HttpHost googleResearch = new HttpHost("research.google.com", 80);
HttpHost wikipediaEn = new HttpHost("en.wikipedia.org", 80);
cm.setMaxPerRoute(new HttpRoute(googleResearch), 30);
cm.setMaxPerRoute(new HttpRoute(wikipediaEn), 50);
DefaultHttpClient client = new DefaultHttpClient(cm);
Token is in the client frequently request data from the server, the server frequently go to the database to query the user name and password and compare, judge whether the user name and password are correct or not, and make the corresponding prompt, in this context, token came into being. A token is a string generated by the server, which is used as a token for the client to request. After the first login, the server generates a token and returns it to the client. In the future, the client only needs to bring the token to request data without bringing the user name and password again
extended data:
token in fact, the more popular point can be called code. Before some data transmission, the code should be checked. Different code is authorized to operate different data. For example, four types of packets are defined in USB1.1 protocol: token packet, data packet, handshake packet and special packet. The continuous data exchange between the host and the USB device can be divided into three stages. In the first stage, the host sends the token packet. Different token packets can tell the device to do different work if they have different contents (different code). In the second stage, the host sends the data packet, and in the third stage, the device returns a handshake packet
, and JSON requests. Different languages have different writing methods. It's just not recommended to do rest operation on the client. If the client_ ID
and client_ The secret is obtained maliciously by others on the client, and the app has great risk.
2. Only the sender and receiver know this key
3. When calling, the sender combines various parameters and generates an access key according to certain rules (various sorting, MD5, IP, etc.)_ key Post together to the API interface
4. The receiver gets the parameters from the post and the access_ key It is also the same as sending, using the key to carry out the same rules for each parameter (various sorting, MD5, IP, etc.) to generate an access_ key2
5. Compare access_ Key and access_ key2 It's the same. Then the operation is allowed. Otherwise, return with an error or join the blacklist.