Here is my code:
String key = Console.ReadLine(); //input oauth2.0 key from google
Console.WriteLine(key);
Google.Apis.Admin.Directory.directory_v1.DirectoryService service = new Google.Apis.Admin.Directory.directory_v1.DirectoryService(new BaseClientService.Initializer
{
ApplicationName = "MY APPLICATION",
ApiKey = key,
});
Google.Apis.Admin.Directory.directory_v1.UsersResource.GetRequest u = service.Users.Get("[email protected]");
Console.WriteLine(u.UserKey);
Google.Apis.Admin.Directory.directory_v1.Data.User response = await u.ExecuteAsync();
Console.WriteLine(response);
Even though I have an OAuth2.0 key "key" from Google, I get an error message in reply saying something along the lines of error: login required. How should I change the code so that I can get (and eventually set) user information without such an error?
EDIT: My scope for the authorization key is the global user scope.
I presume that you are using the Directory API ON Java. Follow this link, https://developers.google.com/admin-sdk/directory/v1/quickstart/java , it is the documentation of the Directory API of Google, and they have given the example for listing users.