The getAllMessages endpoint is a protected API did you request access? export-teams-content
Prerequisites to access Teams Export APIs
Teams Export APIs are currently in preview. It will only be available to users and tenants that have the required licenses for APIs. In the future, Microsoft may require you or your customers to pay additional fees based on the amount of data accessed through the API.
Microsoft Teams APIs in Microsoft Graph that access sensitive data are considered protected APIs. Export APIs require that you have additional validation, beyond permissions and consent, before you can use them. To request access to these protected APIs, complete the request form.
Application permissions are used by apps that run without a signed-in user present; application permissions can only be consented by an administrator. The following permissions are needed:
Chat.Read.All: enables access to all 1:1, Group chat, and meeting chat messages
ChannelMessage.Read.All: enables access to all channel messages
User.Read.All: enables access to the list of users for a tenant