如何模拟一个*只是*创建的用户?

问题描述:

我使用https://developers.google.com/admin-sdk/directory/v1/reference/users/insert在我的域上创建新用户。如何模拟一个*只是*创建的用户?

紧随其后,我想更改其日历设置。当我尝试模拟用户时,出现以下错误:

Signet::AuthorizationError: Authorization failed. Server message: 
{ 
"error": "unauthorized_client", 
"error_description": "Client is unauthorized to retrieve access tokens using this method." 
} 

如果我等待20秒,则不会收到此错误。我该如何立即模仿新创建的用户?

你基本上已经回答了你自己的问题。您有时必须等待一点才能使用新创建的实体。我看到这个处理了an examplegoogle-api-dotnet-client issue您告诉程序本身稍等一下:

Console.WriteLine("OrgUnit inserted: {0}\r\n", insertedOrgUnit.OrgUnitPath); 
    // That should've worked okay. 

    Console.WriteLine("Pausing for ten seconds because sometimes you can't retrieve something immediately after you've created it...\r\n"); 
    System.Threading.Thread.Sleep(10000); 
+0

呀,我实现了一个重试系统来解决这个问题。对这个问题的评价减少了我写答案的动力。我会打勾你的。 –