Python Google Drive Authentification - 错误:admin_policy_enforced

时间:2017-12-06 06:10:10

标签: python google-api google-drive-api gsuite

我正在使用python在Google云端硬盘上上传或下载文件。这是我的代码中最重要的部分:

from httplib2 import Http
from oauth2client import file, client, tools
from apiclient.http import MediaFileUpload
from apiclient import errors
import io
from apiclient.http import MediaIoBaseDownload
from apiclient import errors
import os 
import csv

#####################################
try :
    import argparse
    flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
    flags = None

SCOPES = 'https://www.googleapis.com/auth/drive.file'
store = file.Storage('storage.json')
creds = store.get()

if not creds or creds.invalid:
    print("Create new data storage file ...")
    flow = client.flow_from_clientsecrets('client_secrets.json', SCOPES)
    flow.redirect_uri = client.OOB_CALLBACK_URN
    authorize_url = flow.step1_get_authorize_url()
    creds = tools.run_flow(flow, store, flags) \
            if flags else tools.run(flow, store)
    print ("Storage")

DRIVE = build('drive', 'v2', http=creds.authorize(Http()))

python脚本工作正常2个月。但是从昨天起,如果我开始编写脚本,我会收到此错误:

400. That’s an error.

Error: admin_policy_enforced

Company security policies do not allow this app to connect to your Company account data. Please contact your local helpdesk for any support.

Request Details
client_id=XXXYYYZZZ.apps.googleusercontent.com
redirect_uri=urn:ietf:wg:oauth:2.0:oob
scope=https://www.googleapis.com/auth/drive.file
access_type=offline
response_type=code

直到现在,我的管理员权限一直没有变化。有人有想法吗?

0 个答案:

没有答案