简体   繁体   English

使用Google Translate v2 API访问时出现错误403

[英]Error 403 with Google Translate v2 API access

I am trying to access Google's Translate services from within an Android app. 我正在尝试从Android应用中访问Google的翻译服务。 However, each time I try to access the service (using an HttpGet request), I encounter the following error: 但是,每次我尝试访问该服务(使用HttpGet请求)时,我都会遇到以下错误:

{
 "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. 1.在Google Developer's Console上,创建了一个新项目。
2. From the "APIs and Auth" section on the left, activated the Translate API v2. 2.从左侧的“API和Auth”部分,激活Translate API v2。
3. Generated the SHA1 key with debug.keystore and on the Developer's Console, generated a new key with this information. 3.使用debug.keystore生成SHA1密钥,并在Developer's Console上生成带有此信息的新密钥。
4. Added billing information. 4.添加了帐单信息。 Credit card has been accepted. 信用卡已被接受。
5. Used the following link to access Translate API: 5.使用以下链接访问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. 每次应用程序运行上述Get Request时,都会返回403错误。 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. 我已经浏览了SO或Google可以关注的所有链接,并且似乎没有任何影响它。

Any ideas where I might be going wrong? 我可能会出错的任何想法?

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. 因为您使用Android应用程序(包名称和SHA证书)限制了api密钥,所以必须将这些信息包含在发送给Google的每个请求的标头中。

Read more here . 在这里阅读更多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM