【问题标题】:Google classroom authentication based on Domains基于域的谷歌课堂认证
【发布时间】: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


【解决方案1】:

client_secret.json 文件包含特定于应用程序的凭据,而不是特定于用户或域的凭据。更改 client_secret.json 文件不是登录/注销用户的正确方法。相反,您需要使用具有不同路径的FileDataStore

【讨论】:

    猜你喜欢
    • 2016-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    • 1970-01-01
    相关资源
    最近更新 更多