运行php脚本时遇到问题。
我通过谷歌视觉api检测脸部。
在终端中运行时:
php name.php
我看到输出没有任何问题。 但是当我从网络浏览器运行它时,我遇到了这个错误:
Traceback (most recent call last):
File "test.py", line 139, in <module>
main(args.input_image, args.output, args.max_results)
File "test.py", line 115, in main
faces = detect_face(image, max_results)
File "test.py", line 84, in detect_face
response = request.execute()
File "/usr/local/lib/python2.7/dist-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/http.py", line 838, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://vision.googleapis.com/v1/images:annotate?alt=json returned "Request had insufficient authentication scopes.">
我试着写在终端:
export GOOGLE_APPLICATION_CREDENTIALS= file.json
然后在浏览器中重新打开网页,我仍然有同样的错误。
有什么想法吗?