python - Azure api returns "at least one of the claims 'puid' or 'altsecid' or 'oid' should be present" -
when try access azure api, returns following error.
{u'error': {u'message': u"the received access token not valid: @ least 1 of claims 'puid' or 'altsecid' or 'oid' should present. if accessing application please make sure service principal created in tenant.", u'code': u'invalidauthenticationtoken'}}
have tried following,
endpoint = 'https://management.azure.com/subscriptions/{subscription_id}/providers/microsoft.security/alerts?api-version=2015-01-01' headers = {"authorization": 'bearer ' + access_token} responce = requests.get(endpoint, headers=headers).json() print responce
i suggest use azure sdk python, generic "get":
- example of generic "create" (for kv): https://github.com/azure-samples/resource-magnager-python-resources-and-groups/blob/master/example.py#l54
- generic on readthedocs: http://azure-sdk-for-python.readthedocs.io/en/latest/ref/azure.mgmt.resource.resources.operations.html#azure.mgmt.resource.resources.operations.resourcesoperations.get
use azure-mgmt-resource package: https://pypi.python.org/pypi/azure-mgmt-resource
this package provides authentication user/password or servicecredentials (http://azure-sdk-for-python.readthedocs.io/en/latest/quickstart_authentication.html). can use adal complex scenarios (https://pypi.python.org/pypi/adal/)
(i work @ ms , i'm in charge of python azure)
Comments
Post a Comment