Ich implementieren dies in Python wie folgt:
Code: Select all
def get_authorisation_token(verb, resource_type, resource_id, date, master_key):
key = base64.b64decode(master_key)
text = f"""{verb.lower()}\n{resource_type.lower()}\n{resource_id.lower()}\n{date.lower()}\n\n"""
text_encoded = text.encode('utf-8')
signature_hash = hmac.new(key, text_encoded, digestmod=hashlib.sha256).digest()
signature = base64.b64encode(signature_hash).decode()
key_type = 'master'
version = '1.0'
uri = f'type={key_type}&ver={version}&sig={signature}'
uri_encoded = urllib.parse.quote(uri)
return uri_encoded
Der Teil, den ich nicht herausfinden kann, ist die richtige Kombination aus Ressourcentyp und Ressourcen-ID/Link, um alle Benutzer aus einer bestimmten Datenbank abzurufen. Die Dokumentation finden Sie hier: https://learn.microsoft.com/en-us/rest/ ... list-users
Ich habe einige Kombinationen ausprobiert, aber es kam nichts zurück die Benutzer, ich bekomme nur eine 401:
Code: Select all
{
"code": "Unauthorized",
"message": "The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'get\nusers\ndbs/\nmon, 09 nov 2020 23:37:24 gmt\n\n'\r\nActivityId: 697a4159-f160-4aab-ae90-6cb5eaadb710, Microsoft.Azure.Documents.Common/2.11.0"
}