应用程序默认凭据不存在

时间:2016-07-27 18:19:59

标签: python-2.7 google-app-engine

我一直在尝试使用Google Cloud Vision API来标记和分类图片,但我在使用凭据方面遇到了很多麻烦。我已经在SDK和API管理器本身设置了凭据,并且我已经设置了GOOGLE_APPLICATION_CREDENTIALS环境变量,但是我在仍在输出上运行代码的IDE:

ApplicationDefaultCredentialsError: File C:\Users\elden\Documents\Credentials\My First Project-6c0f3ccb6309 (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!

以下是获取凭据的代码部分:

credentials = gc.get_application_default()
service = build('vision', 'v1', credentials=credentials,discoveryServiceUrl=DISCOVERY_URL)

以下是进口商品:

import argparse
import base64
import httplib2

from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials as gc

我在Windows 10上运行Spyder 2.7.11 32位安装上的代码。

密钥是生成的JSON文件。

1 个答案:

答案 0 :(得分:1)

文件路径需要包含.json扩展名。

相关问题