【问题标题】:Unable to update password - GoogleApiException - Not Authorized to access this resource无法更新密码 - GoogleApiException - 无权访问此资源
【发布时间】:2017-08-09 01:50:46
【问题描述】:

我正在尝试使用 OAuth 2.0 在 GSuite 中更新用户密码

我遇到以下异常:

UpdateEmailUserPassword Google 针对该用户返回了一个错误。请检查 Google 异常详细信息并确保这是一个有效的现有用户

UpdateEmailUserPassword Google 异常详细信息:服务管理员抛出异常:Google.GoogleApiException: Google.Apis.Requests.RequestError 无权访问此资源/api [403] 错误[消息[未授权访问此资源/api]位置[-]原因[禁止]域[全局]

我可以确认所使用的管理员帐户是超级管理员帐户,其中 ClientID 和服务帐户允许使用所有 API 范围。我错过了什么吗?

【问题讨论】:

    标签: google-app-engine google-admin-sdk


    【解决方案1】:

    基于此thread,您需要创建一个service object,并使用代表给定用户的服务帐户授权。尝试将用户成员添加到ServiceAccountCredential.Initializer

    示例:

    ServiceAccountCredential credential = new ServiceAccountCredential(
      new ServiceAccountCredential.Initializer(serviceAccountEmail) 
    
      {
       Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser },
       User = "admin@mydomain.com"  <-------- Added ADMIN User to fix
      }.FromCertificate(certificate));
    

    【讨论】:

      猜你喜欢
      • 2018-11-10
      • 2021-02-15
      • 1970-01-01
      • 1970-01-01
      • 2021-05-19
      • 2014-12-12
      • 2020-07-05
      • 1970-01-01
      • 2020-05-07
      相关资源
      最近更新 更多