Hi @Diya Rawat ,
Sorry for the delayed reply.
You are receiving this error becuase /me/messages Microsoft Graph endpoint or API works with delegated pemissions scope only. As per the screenshot shared above, I do not see either "Mail.Read" or "Mail.ReadBasic" delegated permissions are granted to your app and make sure to grant these delegated permissions to your app to resolve the issue.
https://graph.microsoft.com/v1.0/me/messages?$select=sender,subject
Example:
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.