Menu

Authentication

note: Examples of signatures in different languages:

Refer to the signature implementation logic in the demo code:demo

1 The process description of API request

  • The client generates a key based on the content of the API request, including the HTTP headers and bodies.
  • The client uses MD5 to sign on the key that generated in the first step.
  • The client sends the API request content along with the signed key to the server.
  • After receiving the request, the server repeats the above first and second steps and calculates the expected signature at the server.
  • The server compares the expected signature with the signed key that sent by the client.If they are entirely consistent with eachother, the request can pass the security verification.Otherwise, it will be rejected.

2 Header general request params

params notes sample
X-Up-Key publisher_key X-Up-Key: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql
X-Up-Timestamp Unix timestamp(ms), the millisecond from 1970/1/1. Valid duration is 15 minutes. 1562813567000
X-Up-Signature signature string  

3.3 Params to create signature

params notes sample
Content-MD5 MD5 from HTTP Body string(upper letters) 875264590688CA6171F6228AF5BBB3D2
Content-Type type of HTTP Body application/json
Headers Headers except X-Up-Signature X-Up-Timestamp:1562813567000 X-Up-Key:aac6880633f102bce2174ec9d99322f55e69a8a2
HTTPMethod HTTP method(upper letters) PUT、GET、POST
Resource Path strings from HTTP path /v1/fullreport

3.4 Create signature

Create signature string:

     
SignString = HTTPMethod + "\n" 
                        \+ Content-MD5 + "\n" 
                        \+ Content-Type + "\n"  
                        \+ Headers + "\n"
                        \+ Resource 

MD5Result = MD5(SignString)

X-Up-Signature = ToUpper(MD5Result)

Resource:

    
URL Path and query params

Headers:

   
// X-Up-Key + X-Up-Timestamp (sort by first letter)
// except X-Up-Signature 
Headers = Key1 + ":" + Value1 + '\n' + Key2 + ":" + Value2   

Server will create sign and campare the sign with X-Up-Signature

Last modified: 2025-05-30Powered by