A cloud-based identity and access management service for securing user authentication and resource access
@Alex Wilber , Thank you for reaching out and sharing more details on this. So the problem lies basically in the grant_type that you have used here. Let's go step by step in details:
You used the client_credential flow (using grant_type as client_credetantials) and you used the token issued by that call to call the /users graph API. This is correct and hence you got the response.
But the point to check here is, you got the token in application's context when you used the client_credentials flow. Which would work for the /users API but not for the chats or conversations or such APIs. To call those APIs, you would need the token to be fetched from AAD using the Authorization-Code Grant flow (using the grant type as authorization_code)
Now the following API: https://graph.microsoft.com/beta/users/{user-id}/chats would work only if the following conditions are met:
- You have proper Delegated permissions assigned to your app registration (for eg: Delegated permission - Chat.ReadBasic, Chat.Read, Chat.ReadWrite), Also you if you check the doc for this API "https://learn.microsoft.com/en-us/graph/api/chat-get?view=graph-rest-beta&tabs=http#permissions", you would find that it doesn't support Application permissions (which are used during the client_credentials flow)
- The user-id to be put in the API call should be the userId of the user who in whose context the token was issued. For eg: if you have authenticated yourself using the auth-code grant flow, in that case, the access-token would be issued in your user's context, and hence in the API call, only your user-id needs to be used.
Hope this helps.
Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. If there are still some issues in getting the correct results, do drop us an email on azcommunity[at]microsoft[dot]com with the following details, and we would connect with you offline and discuss this in detail.
Tenant ID/Tenant Name:
Subscription ID:
Do not forget to share the thread URL of this issue so that its easier for me to pick this up and help you further.
Also, please do not forget to accept the response as Answer; if the above response helped in answering your query.