Error 403 with Google Translate v2 API access

只谈情不闲聊 提交于 2019-12-10 17:23:19

问题


I am trying to access Google's Translate services from within an Android app. However, each time I try to access the service (using an HttpGet request), I encounter the following error:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
  ],
  "code": 403,
  "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
 }
}  

I am not able to resolve the above error. I have set up the project as follows:
1. On the Google Developer's Console, created a new project.
2. From the "APIs and Auth" section on the left, activated the Translate API v2.
3. Generated the SHA1 key with debug.keystore and on the Developer's Console, generated a new key with this information.
4. Added billing information. Credit card has been accepted.
5. Used the following link to access Translate API:
https://www.googleapis.com/language/translate/v2?key=myKey&source=en&target=hi&q=hell

Each time the app runs the above Get Request, the 403 error is returned. I have been through all the links that SO or Google can care to throw up on this issue and nothing seems to have affected it.

Any ideas where I might be going wrong?


回答1:


Because you restricted your api key with your android app (package name and SHA certificate), you must include these information to the header of each request sending to google.

Read more here.



来源:https://stackoverflow.com/questions/21075625/error-403-with-google-translate-v2-api-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!