相关疑难解决方法(0)

Youtube API权限403禁止错误

我正在关注页面上的教程,但是当我运行应用程序并尝试进行搜索时,我一直收到403 Forbidden错误.

我在https://console.developers.google.com/页面上启用了Youtube Data API v3,并创建了一个Android API密钥.

有什么建议?谢谢.

Could not search: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"reason" : "ipRefererBlocked",
"extendedHelp" : "https://console.developers.google.com"
} …
Run Code Online (Sandbox Code Playgroud)

youtube android json youtube-api

21
推荐指数
1
解决办法
1万
查看次数

Google如何在API调用中验证SHA1和包名?

在API控制台中注册Android应用以进行Google API访问时,您必须输入应用SHA1证书指纹和应用的包名称.

现在我想知道当api调用只是简单的HTTP请求时,谷歌如何验证这些值是否正确(在最简单的情况下,当你不使用他们的API客户端时,可能附加一些标题值)?您在进行API调用时必须提供API密钥,但这并不能证明输入的值是正确的.

java security android google-api google-authentication

13
推荐指数
1
解决办法
1168
查看次数

谷歌如何验证Android SHA1指纹和包装?

我正在努力使我的Google Translate API工作,但目前我找不到办法.这就是我在Google Developer Console中设置内容的方法:
我已使用调试证书设置了SHA1指纹.和包名 - "bg.webmap.wordy"(实际名称).当我尝试进行调用时,在JSON中返回"ipRefererBlocked"错误.但是当我删除指纹和包名称时,它工作得很好,但是每个人都可以使用这个键,所以它非常不安全.所以我的问题是身份验证.
在调用API时,我的应用会自动发送此指纹吗?我应该自己发送以及如何发送?可能问题出在调试证书中?

android google-api google-translate

9
推荐指数
1
解决办法
1708
查看次数

在Android中使用Google Translate API

我一直在互联网上搜索谷歌翻译API使用,但我找不到下降教程或解释.这就是我所做的:

在我的Google API控制台中,我使用答案使用SHA1指纹在Public API访问下生成了一个键.以下是我的API控制台的外观: 谷歌控制台

在Android工作室中,我使用以下代码使用OkHttp库构建并发送我的请求:

OkHttpClient client = new OkHttpClient();
    String apiKey = "My API key";
    String apiLangSource = "en";
    String apiLangTarget = "de";
    String apiWord = "Hello";
    String googleApiUrl = "https://www.googleapis.com/language/translate/v2?key=" + apiKey + "&source=" + apiLangSource + "&target=" + apiLangTarget + "&q=" + apiWord;
    Request request = new Request.Builder().url(googleApiUrl).build();

    Log.d(TAG, "API STRING" + googleApiUrl);

    Call call = client.newCall(request);

    call.enqueue(new Callback() {
        @Override
        public void onFailure(Request request, IOException e) {
            Log.d(TAG , "HTTP CALL FAIL");
        }

        @Override …
Run Code Online (Sandbox Code Playgroud)

android google-api google-translate

6
推荐指数
1
解决办法
1361
查看次数

Google Place API - 自动完成 - 如何获取邮政编码?

如何强制 Google Place API 的自动完成功能使用邮政编码完成 textView?

我尝试过使用此链接:

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=20&types=postal_code&language=de&sensor=false&key=myKey
Run Code Online (Sandbox Code Playgroud)

获取以20开头的邮政编码,但它不起作用。我从服务器收到以下响应:

{
   "predictions" : [],
   "status" : "INVALID_REQUEST"
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能让它发挥作用>

android json autocompletetextview google-places-api

5
推荐指数
1
解决办法
5194
查看次数

Google Books API - 不断收到错误代码"403"原因:"ipRefererBlocked"

我使用这个作为我的请求网址:

`String isbnUrl = "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn + "&key=" + myAPIKEY;`
Run Code Online (Sandbox Code Playgroud)

谁能告诉我为什么我一直得到这个回应:

{
   "error":{
      "errors":[
         {
            "domain":"usageLimits",
            "reason":"ipRefererBlocked",
            "message":"There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
            "extendedHelp":"https://console.developers.google.com"
         }
      ],
      "code":403,
      "message":"There is a per-IP or per-Referer restriction configured on your API key and the request does …
Run Code Online (Sandbox Code Playgroud)

android google-api

5
推荐指数
1
解决办法
1133
查看次数

如何在 Android 项目中使用谷歌翻译 api v3 将 googleapis/java-translate 库转换为自定义 api rest 请求

由于googleapis/java-translate库,在为我的应用程序构建版本时看到冲突之前,我使用了这些行并且它工作得很好:

    val translate: Translate = TranslateOptions.newBuilder().setApiKey(API_KEY).build().service
    val translations = translate.translate(
         textsToTranslate,
         Translate.TranslateOption.sourceLanguage(sourceLanguage),
         Translate.TranslateOption.targetLanguage(targetLanguage)
    )
Run Code Online (Sandbox Code Playgroud)

然后,在构建 release 时,我不得不在 app/build.gradle 中添加一些额外的代码以使其工作。但是,我看到我的应用程序从 10Mo 增长到 15Mo。只是翻译一些文本就很贵..

所以我决定使用最新的 Google Translate Api v3链接自己执行这些翻译

执行一个简单的 api 休息请求,如下所示:

    val jsonObjectResponse = JSONObject(translate(sourceLanguageCode = sourceLanguage, targetLanguageCode = targetLanguage, textsToTranslate).awaitString())
    val translations = jsonObjectResponse.getJSONArray("translations").toArray { getJSONObject(it) }.map { it.getString("translatedText") }
Run Code Online (Sandbox Code Playgroud)

其中“翻译”功能是:

    private fun translate(sourceLanguageCode: String, targetLanguageCode: String, textsToTranslate: List<String>): Request =
        Fuel.post(path = "https://translation.googleapis.com/v3/projects/$PROJECT_ID:translateText?key=$API_KEY")
            .header(Headers.ACCEPT to "application/json")
            .jsonBody(
                JSONObject().apply {
                    put("contents", JSONArray().apply {
                        textsToTranslate.forEach { text …
Run Code Online (Sandbox Code Playgroud)

api rest android kotlin google-translation-api

5
推荐指数
1
解决办法
221
查看次数

限制在Android时,YouTube API密钥会出现500错误

我很难用一个专门在Android上使用的密钥来查询YouTube搜索API.似乎当我从此密钥中删除限制时,请求正常.当我尝试将其锁定并按照此解决方案中的描述发送证书和程序包标头时,我收到一个非常无用的500错误:

{
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "internalError",
                "message": "Internal Error"
            }
        ],
        "code": 500,
        "message": "Internal Error"
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是我在cURL表单中尝试的请求,其中包含私人信息:

curl -X GET \
  'https://www.googleapis.com/youtube/v3/search/?q=songs&maxResults=25&key=my_api_key&part=snippet' \
  -H 'x-android-cert: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx' \
  -H 'x-android-package: com.xx.xx'
Run Code Online (Sandbox Code Playgroud)

此API 的文档表明仅在StackOverflow上提供支持.是否有任何Google工程师可以帮助我理解为什么会失败?

android youtube-api youtube-data-api

1
推荐指数
1
解决办法
261
查看次数