When I tried above, it gives me the following response
{"statusCode":403,"data":{"authorized":false,"valid":false,"errors":[{"message":{"translation":"User isn't authorized to modify permissions.","args":[]}}],"successful":false},"message":"com.atlassian.confluence.api.service.exceptions.PermissionException: User isn't authorized to modify permissions."}
The user I was trying to use is an admin user and all the permissions have been set to use the REST APIs for this user.
Sorry @jrichards, it was my bad. I didn’t remove the bearer token from the header while trying this. This seem to have worked after removing the authorization header.
Thanks for the update. Basic authentication curl --user <user>:<token> doesn’t need Bearer token as it’s using Basic authentication in the headers (which you can see with curl --verbose). Bearer tokens are usually for Connect apps.