使用属于 Sys Admin 用户的令牌,您可以使用“Assume-User”来模拟另一个用户,如下所述:http: //smartsheet-platform.github.io/api-docs/ ?csharp#assume-user 。
如文档所示,使用“Assume-User”创建连接的 C# 代码如下:
// Set access token.
Token token = new Token();
token.AccessToken = "SYS_ADMIN_TOKEN";
// Create the 'smartsheet' object and set the 'Assume-User' header value to "john.doe@smartsheet.com".
SmartsheetClient smartsheet = new SmartsheetBuilder().SetAccessToken(token.AccessToken).SetAssumedUser("john.doe@smartsheet.com").Build();
创建连接后,您可以通过对该连接执行“获取当前用户”调用来验证您是否以预期的用户身份连接:
// Get current user (call gets executed as "john.doe@smartsheet.com").
UserProfile userProfile = smartsheet.UserResources.GetCurrentUser();
对此调用的响应将包含执行调用的用户的电子邮件、姓名和 ID。例如:
{
"email": "john.doe@smartsheet.com",
"firstName": "John",
"lastName": "Doe",
"id": 48569348493401200
}