I am trying to write a Python script in Jupyter Notebook to connect to the Graph API on behalf of the user. I have successfully managed to acquire access token and retrieved List groups. When I try to request "/groups/{id}/conversations" code returns error.
What I done:
Created App on Azure Directory
- Given below permissions
Delegated and Application Permission: Group.Read.All
- Given admin consent
- Got the Access token using MSAL:
scopes = ['https://graph.microsoft.com/.default']
Create a PublicClientApplication instance
app = PublicClientApplication(client_id, authority=f'https://login.microsoftonline.com/{tenant_id}')
Start the Device Code Flow
result = app.initiate_device_flow(scopes=scopes)
token = app.acquire_token_by_device_flow(result)
access_token = token['access_token']
- Received access token from above API
- Retrieved List groups.
- When sending request on this endpoint "https://graph.microsoft.com/v1.0/groups/{id}/conversations"
I getting error:
Error: 403 - {"error":{"code":"ErrorAccessDenied","message":"Access is denied. Check credentials and try again., User 'user_id' not authorized to access group 'group_mail'. Reason: '(0xD10)'."}}
User is Global admin.