php with python google vision api giving error when loading in browser

186 views Asked by At

I have a problem when running the php script.

I am detecting faces through google vision api.

when running it in the terminal:

php name.php

I am seeing the output without having any problem. But when I am running it from the web browser, I am having this error:

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.">

I tried to write in the terminal:

export GOOGLE_APPLICATION_CREDENTIALS= file.json

and then reopen the webpage in the browser, I still have the same error.

Any idea?

0

There are 0 answers