Signature/tag and Signature parameter: Difference between pages

From SafeStamper API documentation
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
api>Admin
(Created page with "Some API operations require a signature to authenticate the API client. To calculate the signature, follow this steps: * Build a string with all parameters ordered alphabeti...")
 
Line 1: Line 1:
This operation set tag to document
Some API operations require a signature to authenticate the API client.


= URL =
To calculate the signature, follow this steps:
<nowiki>https://www.safestamper.com/api/signature/tag</nowiki>


= Parameters =
* Build a string with all parameters ordered alphabetically, separated by ''&'' and '''without url-encoding'''
* '''sharedkey''': Your API client shared key
* Get the bytes of the string, using UTF-8 encoding
* '''authkey''': Authkey of document owner
* Get the bytes of your private key, using UTF-8 encoding
* '''code''': Code of document to modify
* Calculate the HMAC-SHA1 of the string bytes, with your private key bytes
* '''tag''': Tag to save in the document
* Encode the signature bytes as hexadecimal digit pairs
* '''signature''': Parameters signature, as explained in [[Signature parameter]]


= Returns =
== Example ==


HTTP 200 OK
'''Parameters:'''
* url = <nowiki>https://www.google.com/search?q=Safe+Stamper&gws_rd=cr,ssl</nowiki>
* sharedkey = 789lq9o6im682tl0m1rej34ls


= HTTP Errors =
'''Private key: '''
* 1omnpo704w6u2ad2lxo2wrdm5


* '''401''' Unauthorized: the authkey is not exist
* '''403''' Forbidden: the sharedkey or signature are not valid
* '''404''' Not found: the notification does not exist


= Example =
'''String to sign: '''
<pre>
sharedkey=789lq9o6im682tl0m1rej34ls&url=https://www.google.com/search?q=Safe+Stamper&gws_rd=cr,ssl
</pre>
 


REQUEST:
'''Content bytes''' (hexadeximal):  
<pre>
<pre>
https://www.safestamper.com/api/signature/tag
73 68 61 72 65 64 6b 65 79 3d 37 38 39 6c 71 39  |sharedkey=789lq9|
?authkey=0021d81c-e4a5-4869-8384-2fd70cdb58ec
6f 36 69 6d 36 38 32 74 6c 30 6d 31 72 65 6a 33  |o6im682tl0m1rej3|
&code=b508e6e9-e5f6-4bb5-beef-c89bf6b50764
34 6c 73 26 75 72 6c 3d 68 74 74 70 73 3a 2f 2f  |4ls&url=https://|
&tag=Test
77 77 77 2e 67 6f 6f 67 6c 65 2e 63 6f 6d 2f 73  |www.google.com/s|
&sharedkey=axvmfqn8aex21mxhq5zsj7l482saxfu7j4hh
65 61 72 63 68 3f 71 3d 53 61 66 65 2b 53 74 61  |earch?q=Safe+Sta|
&signature=b1b22b34967fdf2eb67c3569a1e8b90f9fb63e77
6d 70 65 72 26 67 77 73 5f 72 64 3d 63 72 2c 73  |mper&gws_rd=cr,s|
73 6c                                            |sl|
</pre>
</pre>


RESPONSE:


HTTP 200 OK
'''Key bytes''' (hexadecimal)
<pre>
31 6f 6d 6e 70 6f 37 30  34 77 36 75 32 61 64 32  |1omnpo704w6u2ad2|
6c 78 6f 32 77 72 64 6d  35 0a                    |lxo2wrdm5.|
</pre>
 
 
'''HMAC-SHA1'''
<pre>
3e e8 b6 11 39 50 c0 c8 49 4b a0 3b 4f b8 d6 16 c7 fb 9a 25
</pre>
 
 
'''Signature string:'''
<pre>
3ee8b6113950c0c8494ba03b4fb8d616c7fb9a25
</pre>

Revision as of 13:40, 1 December 2016

Some API operations require a signature to authenticate the API client.

To calculate the signature, follow this steps:

  • Build a string with all parameters ordered alphabetically, separated by & and without url-encoding
  • Get the bytes of the string, using UTF-8 encoding
  • Get the bytes of your private key, using UTF-8 encoding
  • Calculate the HMAC-SHA1 of the string bytes, with your private key bytes
  • Encode the signature bytes as hexadecimal digit pairs

Example

Parameters:

  • url = https://www.google.com/search?q=Safe+Stamper&gws_rd=cr,ssl
  • sharedkey = 789lq9o6im682tl0m1rej34ls

Private key:

  • 1omnpo704w6u2ad2lxo2wrdm5


String to sign:

sharedkey=789lq9o6im682tl0m1rej34ls&url=https://www.google.com/search?q=Safe+Stamper&gws_rd=cr,ssl


Content bytes (hexadeximal):

73 68 61 72 65 64 6b 65 79 3d 37 38 39 6c 71 39  |sharedkey=789lq9|
6f 36 69 6d 36 38 32 74 6c 30 6d 31 72 65 6a 33  |o6im682tl0m1rej3|
34 6c 73 26 75 72 6c 3d 68 74 74 70 73 3a 2f 2f  |4ls&url=https://|
77 77 77 2e 67 6f 6f 67 6c 65 2e 63 6f 6d 2f 73  |www.google.com/s|
65 61 72 63 68 3f 71 3d 53 61 66 65 2b 53 74 61  |earch?q=Safe+Sta|
6d 70 65 72 26 67 77 73 5f 72 64 3d 63 72 2c 73  |mper&gws_rd=cr,s|
73 6c                                            |sl|


Key bytes (hexadecimal)

31 6f 6d 6e 70 6f 37 30  34 77 36 75 32 61 64 32  |1omnpo704w6u2ad2|
6c 78 6f 32 77 72 64 6d  35 0a                    |lxo2wrdm5.|


HMAC-SHA1

3e e8 b6 11 39 50 c0 c8 49 4b a0 3b 4f b8 d6 16 c7 fb 9a 25


Signature string:

3ee8b6113950c0c8494ba03b4fb8d616c7fb9a25