0

When using DriveService.Permission.List(), you get a list of permissions for a specific file. But there is nothing there to uniquely identify the user account that has the permission. I found somewhere that one can add https://www.googleapis.com/auth/userinfo.email to the scopes list to achieve this, but this just gives me bad request with what would otherwise work.

Is there some way to get the usernames involved? I'm using a service account, as it is not possible to use the OAuth2 with copy pasting passwords...

I know that this can be done with Documents List API, but I don't want to use a deprecated API.

1 Answer 1

1

You need to authorize for https://www.googleapis.com/auth/userinfo.email and https://www.googleapis.com/auth/userinfo.email and request for user profile by making the request below.

GET https://www.googleapis.com/userinfo/v2/me 

You can give it a try on API Explorer: https://developers.google.com/apis-explorer/#p/oauth2/v2/oauth2.userinfo.v2.me.get

Sign up to request clarification or add additional context in comments.

5 Comments

I'm using the .NET client. I added googleapis.com/auth/userinfo.email to the scopes, but that just gives me bad request. I also added that line to the domain's "Manage API client access" scope line for the service account. Do I need to add some service to the API console for my account? And even then, how will this link a permission to a user account?
Is the ServiceAccount not enought to be able to accomplish this?
Apparently, I don't get more info with OAuth2... So the question remains... I don't know how to do what you ask me to do with the .NET client.
What do you mean by a service account performing this action? If you're asking for service account's profile, it may behave differently. Please send code snippets when you receive bad requests.
I gave up and used the deprecated Documents list API, which solved the problem. But the question remains - How to do it with Google Drive API. @Burcu: I'm using a service account to access a domain's Drive. I want to see who has access to a given file. But I don't get a list of usernames, or any other way of identifying who has access.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.