繁体   English   中英

Python Google Analytics OAuth 服务帐户和 2LO; “sub”参数和域范围的委派

[英]Python Google Analytics OAuth Service Account and 2LO; "sub" parameter and domain wide delegation

我在一些关于使用sub参数的报告中阅读了一些评论(这就是我的理解),当与凭证对象一起传递给带有服务帐户的 2LO 的谷歌分析时,可以用作替代用于通过我如下图所示的管理控制台手动直接授权一个帐户。

在此处输入图片说明

分析 Google API 错误 403:“用户没有任何 Google Analytics 帐户”

我认为如果我通过'sub': 'superuseremail@account.com'它将取代在 GA 中手动设置帐户权限,我的理解是错误的吗?

更重要的是,我通过帐户权限获得了对 Google Analytics 帐户的访问权限(例如,我没有超级用户权限或超级用户电子邮件的访问权限),并且我使用该电子邮件传递了此sub参数。 我在尝试这条路线时收到 403 错误。

简单地说:

访问我正在收集的服务帐户的唯一方法是访问超级用户电子邮件并通过手动添加服务帐户电子邮件来管理帐户权限,或者使用具有sub电子邮件的credentials对象传递sub参数那是正确的超级用户电子邮件吗?

TLDR:不! ,Google Analytics 不是G-Suite产品,并且服务帐户在未经直接授权的情况下无权访问他人的 G-Suite 帐户

如果您仔细查看相关方法源代码

def create_delegated(self, sub):
    """Create credentials that act as domain-wide delegation of authority.
    Use the ``sub`` parameter as the subject to delegate on behalf of
    that user.
    For example::
      >>> account_sub = 'foo@email.com'
      >>> delegate_creds = creds.create_delegated(account_sub)
    Args:
        sub: string, An email address that this service account will
             act on behalf of (via domain-wide delegation).
    Returns:
        ServiceAccountCredentials, a copy of the current service account
        updated to act on behalf of ``sub``.
    """
    new_kwargs = dict(self._kwargs)
    ...

您将看到此服务帐户将通过域范围委派代表用户进行操作

那么你的问题的答案是“什么是域范围委托?”。

在企业应用程序中,您可能希望以编程方式访问用户的数据,而无需他们进行任何手动授权。 在 G-Suite 域中,域管理员可以授予第三方应用程序在域范围内访问其用户数据的权限——这称为域范围授权。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM