That seems easy enough, but there's something I don't understand. Where does the accessing user's identity come into play?
If I follow the directions the SO answer links to, I end up with something like this:
def adminPermission():
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
service = discovery.build('cloudresourcemanager', 'v1', credentials=credentials)
resource = "my-project-name"
test_iam_permissions_request_body = {
"permissions": [
"resourcemanager.projects.get"
]
}
request = service.projects().testIamPermissions(resource=resource, body=test_iam_permissions_request_body)
response = request.execute()
return len(response.get("permissions",[])) == 1
But all I'm checking in that code is whether my project has project permission, not whether the user making the request has project permission. If I hit a URL from curl with no auth that is returning True, since of course, my project has permission to get itself.
How do I get the credentials of the user accessing the URL?
-Joshua