karishmal / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

403 response after multiple successful requests #452

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a loop of approx. 100 runs
2. Place following code in the loop:
while (i < 100)
{
    Console.WriteLine("================== Start run "+ i + " =======================");

    String serviceAccountEmail = "#####@developer.gserviceaccount.com";
    X509Certificate2 certificate = new X509Certificate2(@"pathtocert", "notasecret", X509KeyStorageFlags.Exportable);

    ServiceAccountCredential credential = new ServiceAccountCredential(
        new ServiceAccountCredential.Initializer(serviceAccountEmail)
        {
            Scopes = new[] { 
                DirectoryService.Scope.AdminDirectoryUser.ToString(), DirectoryService.Scope.AdminDirectoryUserReadonly.ToString(),
                DirectoryService.Scope.AdminDirectoryGroup.ToString(), DirectoryService.Scope.AdminDirectoryGroupReadonly.ToString(),
                DirectoryService.Scope.AdminDirectoryOrgunit.ToString()
            },
            User = "admin@gmail.com"
        }.FromCertificate(certificate)
    );
    DirectoryService service = new DirectoryService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Bla" });

    UsersResource.GetRequest req = service.Users.Get("test@test.com");
    req.Alt = UsersResource.GetRequest.AltEnum.Json;
    Google.Apis.Admin.Directory.directory_v1.Data.User test = req.Execute();

    Console.WriteLine("ID: " + test.Id);
    Console.WriteLine("Name: " + test.Name.FullName);
}
3. run the application

What is the expected output? What do you see instead?
The expected output is 100 successful runs, instead we get an error after  
approx. 10-20 runs.

What version of the product are you using?
- Google.Apis.Admin.Directory.directory_v1 1.8.0.28
- Google.Apis.Authentication.OAuth2 1.6.0.16918

What is your operating system? Win 7 
What is your IDE? Visual studio 2013 ultimate
What is the .NET framework version? 4.0/4.5

Please provide any additional information below.
After some testing we found out the the service return a 403 webpage. 

Original issue reported on code.google.com by dhrfrijl...@gmail.com on 13 Mar 2014 at 12:37