【问题标题】:Google+ API rate limit for OAuth based authentication for multiple users针对多个用户的基于 OAuth 的身份验证的 Google+ API 速率限制
【发布时间】:2015-04-14 07:21:11
【问题描述】:

基于 OAuth 的 G+ 身份验证是否有任何 API 速率限制。

场景

假设有 1000 多人同时点击我的代码来验证他们的 G+ 帐户。

我正在使用 googleapis nodejs 模块进行身份验证

var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var plus = google.plus('v1'); 
var oauth2Client = new OAuth2(appId, appSecret, callbackURL);
    var scopes = [
                  'https://www.googleapis.com/auth/plus.me',
                  'https://www.googleapis.com/auth/userinfo.email'
                  ];
    var url = oauth2Client.generateAuthUrl({
        access_type: 'offline', // 'online' (default) or 'offline' (gets refresh_token) 
        scope: scopes // If you only need one scope you can pass it as string 
    });


    oauth2Client.getToken(googleCode, function(err, tokens) {
        if(!err) {
            oauth2Client.setCredentials(tokens);
            logger.debug(":: G+ access token ::" + JSON.stringify(tokens));
            var accessTokenJsonObj = JSON.stringify(tokens);
            oauth2Client.setCredentials({
                access_token: tokens.access_token,
                refresh_token: tokens.refresh_token
            });
            plus.people.get({ userId: 'me', auth: oauth2Client }, function(err, response) {
                // handle err and response 
                if(!err) {
                }
            }
     }

通过查看谷歌文档,我得到了以下详细信息。

每个用户限制:5 个请求/秒/用户

对于基于 OAuth 的身份验证针对多个用户

,每天是否有任何 API 速率限制

谢谢

【问题讨论】:

    标签: node.js google-api google-plus google-oauth


    【解决方案1】:

    身份验证本身没有限制(据我所知),但对 Google+ API 的调用是有限的。

    plus.people.get 调用使用您的登录配额,默认情况下每天允许 20,000,000 次请求,总计适用于您的所有用户,因此,如果您没有对 Google+ API 进行任何其他调用,则您可以处理 20,000,000 次登录天。

    您可以通过选择您的项目 > APIs & Auth > APIs > Enabled APIs > Google+ API > Quotas 查看Google Developers Console 中的配额。

    如有必要,您还可以从该页面请求更多配额。

    【讨论】:

      【解决方案2】:

      此外,如果您使用交换 refresh_tokens,授权代码响应包括一个 id_token,该 id_token 对 user_id 进行编码。

      因此,您可以避免在每次登录时都调用 people.get API - 尽管您可能希望这样做以保持用户的个人资料为最新。

      更多信息请见https://developers.google.com/identity/protocols/OpenIDConnect?hl=EN#obtainuserinfo

      【讨论】:

        猜你喜欢
        • 2021-10-10
        • 1970-01-01
        • 1970-01-01
        • 2018-07-22
        • 2014-05-02
        • 2013-10-20
        • 2015-04-09
        • 2021-02-08
        • 1970-01-01
        相关资源
        最近更新 更多