We ran into a problem that is quite confusing - we have a user trying to access the endpoint:
Thanks for being here and our apologies for the delay in response. If you're still experiencing this, please reach out at https://support.github.com/ so we can take a look.
Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!
Can you check whether the user is an admin for that repo? Or is he in a team that has admin access to the repo? Because branch protection is something that is restricted.
In the below example you can see that I can able to get the master branch details but I cannot get the branch protection details since I am not the admin for that repo.