【问题标题】:G Suite Service Account Fails Requests But Delegation Works?G Suite 服务帐户请求失败但委托有效?
【发布时间】:2019-08-16 16:30:50
【问题描述】:

我已按照创建 G Suite 服务帐号的文档进行操作。以下可以很好地模拟我域中的给定用户:

def create_directory_service(user_email):

    credentials = ServiceAccountCredentials.from_json_keyfile_name(
        SERVICE_ACCOUNT_FILE_PATH,
        scopes = SCOPES)

    credentials = credentials.create_delegated(user_email)

    return build('admin', 'directory_v1', credentials=credentials)

但是,我希望能够只使用服务帐户来访问域信息,而无需模拟特定用户。但是,如果我传入服务帐户的电子邮件地址(在其密钥文件中给出),我只会得到HttpError 503: "Service unavailable. Please try again"

我已将服务帐户的电子邮件地址添加为 Service Account Admin,但仍然无法使用。同样,委派工作正常,但不直接使用服务帐户。

有人知道我错过了什么吗?

【问题讨论】:

    标签: oauth-2.0 credentials google-workspace service-accounts google-groups


    【解决方案1】:

    要使用 Directory API,您必须使用委托来模拟域中的用户,该用户可以使用 Directory API(通常是管理员)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-23
      • 1970-01-01
      • 2018-02-01
      • 2018-02-19
      • 2020-11-28
      • 2017-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多