I am using the following API to export the group chats.
https://graph.microsoft.com/beta/teams/{id}/channels/getAllMessages
I am getting the following response:
{'error': {'code': 'Forbidden',
'innerError': {'client-request-id': '59b79800-e6fe-47ab-b046-a934aea57628',
'date': '2021-04-06T11:55:55',
'request-id': '59b79800-e6fe-47ab-b046-a934aea57628'},
'message': 'Forbidden'}}
As a prerequisite I have filled a form for request access and the same has been approved.
Also, I have given the required permissions (User.Chat.All, Read.Chat.All) to the application as mentioned in this link.
https://docs.microsoft.com/en-us/microsoftteams/export-teams-content
Also I tried to export the users chats using following API and it works perfectly fine.
https://graph.microsoft.com/beta/users/{id}/chats/getAllMessages