如何模拟*刚*创建的用户?
How to impersonate a *just* created user?
我正在使用 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 example on a google-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);
我正在使用 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 example on a google-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);