Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

javascript - 无法验证google cloud vision API。 如何对其进行身份验证以进一步使用它(Not able to autheticate google cloud vision api . How to autheticate it to use it further)

My Code looks like this :-

(我的代码如下所示:)

var vision = require('@google-cloud/vision');
handleSubmit = () =>{ 
        console.log("encoded string submitted=",this.state.files);            
        this.useVisionCloud();
    }

    useVisionCloud = () =>{

            const client = new vision.ImageAnnotatorClient();
            const request_body = {
                "requests": [
                  {
                    "image": {
                      "content": this.state.files
                    },
                    "features": [
                      {
                        "type": "TEXT_DETECTION"
                      }
                    ]
                  }
                ]
              };
              client.textDetection(request_body).then(response => {
                    console.log("text got=",response);                    
                  // doThingsWith(response);
                })
                .catch(err => {
                    console.log("error got=",err);   
                });
    }
  1. I already tried setting environment variable but didn't work .

    (我已经尝试设置环境变量,但是没有用。)

  2. I have also created service account and downloaded the file.json but dont know how to use it for authentication

    (我还创建了服务帐户并下载了file.json, 但不知道如何使用它进行身份验证)

im getting the following error :-

(即时通讯收到以下错误:)

Uncaught Error: {"clientConfig":{},"port":443,"servicePath":"vision.googleapis.com","scopes":["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloud-vision"]}You need to pass auth instance to use gRPC-fallback client in browser. Use OAuth2Client from google-auth-library.

on triggering a post request to Google API .

(触发对Google API的发布请求。)

Final Query is :- I am not able to understand how to authenticate API so that i can further use it to detect text in my images

(最终查询是:-我无法理解如何对API进行身份验证,以便我可以进一步使用它来检测图像中的文本)

  ask by Aully translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...