Happy to hear you are no longer experiencing this issue :)
Posting here for everyone else's benefit...
If you see an issue like this, it means that there is an authentication header mismatch between the application and database. This can be a result of many things... including an incorrect auth key, system clocks out of sync, or an issue with how the auth header is generated.
First-Party DocumentDB SDKs
If you are using one of DocumentDB's 1st party client SDKs - it's most likely an incorrect auth key or a system clock issue...
If those look good, than there is a bug on DocumentDB's end. If you are experiencing issues - please contact me (askcosmosdb {at} microsoft.com) with a few activity ids + timestamps + stacktrace, and I can help you look in to the issue.
Rest API
The header is rather tricky to put together... Here are some tips for constructing the auth header:
All parameters (verbs, resource type, date, etc.) must be lower case prior to signing EXCEPT when using id-based routing.
For id-based routing, you will need to sign the full path to the resource (e.g. dbs/MyDatabase/colls/MyCollection/docs/MyDocument
); not just the resource's id (e.g. MyDocument
). Please note that the path is case-sensitive... while, all the other parameters should be lower case.
The key is Base64 encoded.
The text to be signed should be utf-8 encoded.
The generated auth token is a SHA256 HMAC and should be Base64 encoded.
As with all HTTP headers, the signature (including the signed token) should be URL encoded (e.g. +
needs to be encoded as %2B
).
Full documentation and sample code, see: https://msdn.microsoft.com/en-US/library/azure/dn783368.aspx