【问题标题】:How to impersonate a *just* created user?如何冒充*刚刚*创建的用户?
【发布时间】:2017-08-25 02:30:42
【问题描述】:

我正在使用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 秒,我不会收到此错误。如何立即模拟新创建的用户?

【问题讨论】:

    标签: google-admin-sdk


    【解决方案1】:

    您基本上已经回答了自己的问题。您有时需要稍等片刻才能使用新创建的实体。我在google-api-dotnet-client issue 上的an example 中看到了这个问题,你告诉程序本身稍等一下:

        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);
    

    【讨论】:

    • 是的,我实现了一个重试系统来解决这个问题。对这个问题的反对削弱了我写答案的动力。我会勾选你的。
    猜你喜欢
    • 2017-09-04
    • 2016-12-09
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-18
    • 2011-05-04
    相关资源
    最近更新 更多