403 Forbidden using users.List() method, Service Account in Google Cloud:
Hello iám using these nuggets:
<PackageReference Include="Google.Apis.Auth" Version="1.60.0" />
<PackageReference Include="Google.Apis.Admin.Directory.directory_v1" Version="1.60.0.3064" />
code:
ServiceAccountCredential credential;
using (var stream = new FileStream(basePath, FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream)
.CreateScoped(DirectoryService.Scope.AdminDirectoryUserReadonly)
.UnderlyingCredential as ServiceAccountCredential;
}
DirectoryService service = new DirectoryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "nombre"
});
var request = service.Users.List();
request.Customer = "customerId";
var users = request.Execute();
I already added the necessary roles in the google cloud console and I send it the necessary scopes, but it still gives me a 403 forbidden error, what could it be?