Microsoft Security | Microsoft Graph
An API that connects multiple Microsoft services, enabling data access and automation across platforms
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi all,
how do I paginate in the API for cloud app security api?
im currently working with the requests Python package.
AZURE_CLIENT_ID = os.getenv("AZURE_CLIENT_ID")
AZURE_CLIENT_SECRET = os.getenv("AZURE_CLIENT_SECRET")
AZURE_TENANT_ID = os.getenv("AZURE_TENANT_ID")
RESOURCE_ID = os.getenv("RESOURCE_ID")
def get_access_token_cloud_app() -> str:
""" Get access token for graph API
Returns:
str: Access token
"""
auth_url = f"https://login.microsoftonline.com/{AZURE_TENANT_ID}/oauth2/token"
auth_body = {
'resource': RESOURCE_ID,
'client_id': AZURE_CLIENT_ID,
'client_secret': AZURE_CLIENT_SECRET,
'grant_type': 'client_credentials'
}
auth_response = requests.post(url=auth_url, data=auth_body, timeout=300)
auth_response_json = auth_response.json()
aad_token = auth_response_json["access_token"]
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f"Bearer {aad_token}"
}
return headers
headers = get_access_token_cloud_app()
url = "https://<tenant_id>.<tenant_region>.cloudappsecurity.com/api/v1/discovery/discovered_apps/"
response = requests.get(url=url, headers=headers, timeout=300)
Hope you can help!
Best regards
Sarah
An API that connects multiple Microsoft services, enabling data access and automation across platforms