SamiHuutoniemi
SamiHuutoniemi

Reputation: 1595

Need to get username with file permissions

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.

Upvotes: 0

Views: 431

Answers (1)

Burcu Dogan
Burcu Dogan

Reputation: 9213

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

Upvotes: 1

Related Questions