GCP python错误:创建teamdrive时,“用户对此文件没有足够的权限”

时间:2019-05-09 15:31:00

标签: python google-cloud-platform google-drive-team-drive

在将teamdrives集合迁移到驱动器后,我试图使用Google Drive API创建一个团队驱动器。但是我有一个许可错误。

@endpoints.method(
    TEAM_DRIVE_RESOURCE,
    TeamDriveMessage,
    path='create',
    http_method='POST',
    name='create')
def create_team_drive(self, request):
    try:
        logger = logging.getLogger()
        team_drive_service = Services().get_team_drive_service()
        request_id = str(uuid.uuid4())
        response_team_drive = team_drive_service.drives().create(
            body={"name": request.customerName + " | " + request.appName,
                  }, requestId=request_id).execute()
        logger.info(response_team_drive)
    except HttpError as error:
        if error.resp.status < 500:
            raise endpoints.BadRequestException(error._get_reason())
        raise endpoints.InternalServerErrorException(error._get_reason())
    return TeamDriveMessage(teamDriveId=response_team_drive.id)

这是获得团队合作精神服务的代码

@staticmethod
def get_team_drive_service():
    credentials = ServiceAccountCredentials.from_json_keyfile_name(
        SERVICE_ACCOUNT_FILE,
        scopes=['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file', 'https://www.googleapis.com/auth/drive.appdata', 'https://www.googleapis.com/auth/drive.apps.readonly'])
    team_drive_service = googleapiclient.discovery.build('drive', 'v3', credentials=credentials)
    return team_drive_service

错误消息:

{   “错误”:{     “代码”:400,     “错误”:[       {         “ domain”:“ global”,         “ message”:“用户对该文件没有足够的权限。”,         “原因”:“ badRequest”       }     ],     “ message”:“用户对该文件没有足够的权限。”   } }

permissions assigned to the account service

0 个答案:

没有答案