Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我需要将google身份验证写入环境变量_Python_Google Drive Api - Fatal编程技术网

Python 我需要将google身份验证写入环境变量

Python 我需要将google身份验证写入环境变量,python,google-drive-api,Python,Google Drive Api,现在公司需要将client_secret_2.json和credentials.json文件的内容写入环境变量,但我只知道环境变量的路径我不熟悉google drive API,但要用Python设置环境变量,需要执行以下操作: SCOPES = 'https://www.googleapis.com/auth/drive.readonly' filename = settings.GOOGLE_CREDENTIALS_PATH store = file.Storage(filename) cr

现在公司需要将client_secret_2.json和credentials.json文件的内容写入环境变量,但我只知道环境变量的路径

我不熟悉google drive API,但要用Python设置环境变量,需要执行以下操作:

SCOPES = 'https://www.googleapis.com/auth/drive.readonly'
filename = settings.GOOGLE_CREDENTIALS_PATH
store = file.Storage(filename)
creds = store.get()

if not creds or creds.invalid:
    flow = client.flow_from_clientsecrets(settings.GOOGLE_CLIENT_SECRET_PATH, SCOPES)
    creds = tools.run_flow(flow, store)
所以我假设您需要将
client\u secret\u 2.json
credentials.json
中的键/值对设置为环境变量

import os

os.environ["key"] = "value"