【发布时间】:2015-08-20 13:33:36
【问题描述】:
目前我正在研究谷歌教室 API 以将教室集成到我的 .NET 产品中。我的问题是当我执行此方法时,它第一次要求身份验证,但是当我下次执行此代码时,它直接以以前的登录方式登录凭据。即使我更改了另一个(第二个)域的 client_secret.json,它也直接以第一个域身份验证用户身份登录。我的要求是当我在运行时在代码中动态更改 client_secret.json 文件时它将直接以该 client_secret.json 文件的域用户而不是 client_secret.json 文件的先前域用户身份登录。这可能吗? 如果是,我该如何实现。请任何人帮忙。
private ClassroomService getservice()
{
using (var stream =
new FileStream(Server.MapPath("client_secret.json"), FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
var service = new ClassroomService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
return service;k
}
【问题讨论】:
-
感谢您的回复@Eric Koleda。但我的要求不同。我需要在两个用户之间切换,管理员根据运行时的client_secret.json文件更改直接以经过身份验证的用户身份登录。我怎样才能做到这一点
标签: google-classroom