duanpacan9388 2018-05-21 11:07
浏览 128

来自Google NLP的演示应用无法正常工作 - “代码”:403

Could some one help me with sample application from this site: https://cloud.google.com/natural-language/docs/quickstart-client-libraries#client-libraries-install-php. I did, at least I think I did, everything what is required. And I am constantly getting error 403:

Fatal error: Uncaught exception 'Google\Cloud\Core\Exception\ServiceException' with message '{ "error": { "code": 403, "message": "The request is missing a valid API key.", "status": "PERMISSION_DENIED" } } ' in C:\Users\Admin\Dropbox\HTDOCS
lp\vendor\google\cloud\Core\src\RequestWrapper.php:263 Stack trace: #0 

C:\Users\Admin\Dropbox\HTDOCS
lp\vendor\google\cloud\Core\src\RequestWrapper.php(168): Google\Cloud\Core\RequestWrapper->convertToGoogleException(Object(GuzzleHttp\Exception\ClientException)) #1 

C:\Users\Admin\Dropbox\HTDOCS
lp\vendor\google\cloud\Core\src\RestTrait.php(96): Google\Cloud\Core\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array) #2 

C:\Users\Admin\Dropbox\HTDOCS
lp\vendor\google\cloud\Language\src\Connection\Rest.php(69): Google\Cloud\Language\Connection\Rest->send('documents', 'analyzeSentimen...', Array) #3 

C:\Users\Admin\Dropbox\HTDOCS
lp\vendor\google\cloud\Language\src\LanguageClient.php(221): Google\Cloud\Language\Connection\Rest->analyzeSentiment(Array) #4 

C:\Users in C:\Users\Admin\Dropbox\HTDOCS
lp\vendor\google\cloud\Core\src\RequestWrapper.php on line 263 
  • 写回答

1条回答 默认 最新

  • dsh7623 2018-05-28 09:08
    关注

    You have to create a service account with permissions for this API, and then download a private key as a JSON file. It is mentioned in the tutorial you were following, but you can also do that via the command line like in here.

      $ gcloud iam service-accounts create my-account
      $ gcloud iam service-accounts keys create key.json
        --iam-account=my-account@my-project.iam.gserviceaccount.com
      $ export GOOGLE_APPLICATION_CREDENTIALS=key.json
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c