如何获取 Google oauth 客户端访问令牌?

时间:2021-06-30 04:45:41

标签: oauth-2.0 google-oauth token openid-connect access-token

我想知道获取 Google OAuth 客户端访问令牌的 API。

当我携带访问令牌时,我只想使用 client_id、client_secret、user_name 和 user_password。 (因为使用redirect uri的方法不适用)

例如

   public static List<string> mostActive(List<string> customers)
    {
        List<string> res = new List<string>();
        foreach (var c in customers)
        {
            double count = customers.Count(a => a.Contains(c));
            double per = (count / customers.Count()) * 100;
            if (!res.Contains(c) && per>=5)
            {
                res.Add(c);
            }
        }
        return res.OrderBy(r=>r).ToList();
    }

所以.. 有没有可能想知道它是否可以导入到grant-type = password? https://developer.okta.com/blog/2018/06/29/what-is-the-oauth2-password-grant

帮帮我...

1 个答案:

答案 0 :(得分:1)

您所指的称为客户端登录。这是一种使用登录名和密码获取访问令牌的方法。

Google shut down client login in 2015

<块引用>

为了消除仅使用密码的身份验证,我们迈出了第一步,三年前宣布 ClientLogin 的弃用日期为 2015 年 4 月 20 日。同时,我们推荐 OAuth 2.0 作为我们 API 的标准身份验证机制。使用 OAuth 2.0 的应用程序从不要求用户输入密码,并且用户可以更严格地控​​制客户端应用程序可以访问的数据。您可以使用 OAuth 2.0 构建客户端和网站,以安全地访问帐户数据并使用我们的高级安全功能(例如两步验证)。

您现在需要使用 Oauth2。让您的用户运行您的应用程序并在他们完成后同意您访问他们的数据,您将获得访问令牌。

Google 授权服务器不允许使用 Gant 类型的密码。

<块引用>

因为使用redirect uri的方法不适用

只有当您安装了应用程序或移动应用程序时,Web 应用程序才需要重定向 uri。

相关问题