首页 > 解决方案 > 使用服务帐户返回密钥错误的 Google API

问题描述

我不确定我在这里做错了什么,这里的代码基本上取自文档。但是,在运行此代码时,我收到一个关键错误:access_token:

from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials

SCOPES = ['https://www.googleapis.com/auth/admin.directory.user'
          'https://www.googleapis.com/auth/admin.directory.group.member',
          'https://www.googleapis.com/auth/admin.directory.group.member.readonly',
          'https://www.googleapis.com/auth/admin.directory.group.readonly']
credentials = ServiceAccountCredentials.from_json_keyfile_name(
      'keyfilecredentials.json',
      scopes=SCOPES)
service = build('admin', 'directory_v1', credentials=credentials)
list = service.users().list().execute()

标签: pythongoogle-api-clientservice-accounts

解决方案


推荐阅读