谷歌图书API 403访问未配置 [英] Google Books API 403 Access Not Configured

查看:109
本文介绍了谷歌图书API 403访问未配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图联系谷歌图书API和执行一个标题搜索,这仅需要一个公共的API密钥和没有的oauth2。我得到的是以下错误:

I'm trying to contact the Google Books API and perform a title search, which only requires a public API key and no OAUTH2. All I get is the following error:

{
    "error": {
        "errors": [
        {
            "domain": "usageLimits",
            "reason": "accessNotConfigured",
            "message": "Access Not Configured"
        }
        ],
        "code": 403,
        "message": "Access Not Configured"
    }
}

有一派周围小时后,似乎很多人有同样的问题,但与其他谷歌的API。什么我迄今所做的:

After having googled around for hours, it seems many others have the same problem but with other Google APIs. What I've done so far:


  1. 在我注册开发项目控制台

  2. 已启用的书籍API

  3. 签名我的应用程序,以获得SHA1证书编号

  4. 偏偏下载适用于Android的公开API密钥在我的开发者控制台

  5. 粘贴下面的字符串到公共API密钥的形式,为了拿到钥匙:SHA1号; com.package,不带引号

  6. 复制粘贴生成的密钥到我的code。

在code如下所示:

private void callGoogleBooks(){
    String key = MY_KEY;
    String query = "https://www.googleapis.com/books/v1/volumes?q=flowers+inauthor:keyes&key=" + key;
    Log.d("google books", callApi(query));
}

public String callApi(String query){
    HttpClient httpClient = new DefaultHttpClient();
    HttpGet getRequest = new HttpGet(query);
    HttpResponse httpResponse = null;

    try{
        httpResponse = httpClient.execute(getRequest);
    } catch(UnsupportedEncodingException e){
        Log.d("ERROR", e.getMessage());
    } catch(ClientProtocolException e){
        Log.d("ERROR", e.getMessage());
    } catch (IOException e){
        Log.d("ERROR", e.getMessage());
    }

    if(httpResponse != null){
        try{
            HttpEntity httpEntity = httpResponse.getEntity();
            InputStream is = httpEntity.getContent();
            BufferedReader br = new BufferedReader(
                    new InputStreamReader(is, "utf-8"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while((line = br.readLine()) != null){
                sb.append(line + "\n");
            }
            is.close();
            String responseString = sb.toString();
            return responseString;
        } catch (Exception e){
            Log.d("ERROR", e.getMessage());
        }
    }
    return null;
}


  • 是否有任何明显的错误?我需要格式化或不同的包装我的要求?

  • 请我需要添加任何东西的清单文件?

  • 当指定程序包生成公共API密钥的时候,我需要指定相同的包名称作为我的应用程序结构?我读的地方,它必须是唯一的,但将其更改为不太可能是一个重复导致同样的错误的东西。

  • 错误显然有usageLimits做的,但我不是,甚至接近每日允许的在我的测试项目中的1000呼叫的1%。

    The error apparently has to do with "usageLimits", but I'm not even close to 1% of the 1000 calls allowed per day in my test project.

    我也尝试实施<一个href=\"https://$c$c.google.com/p/google-api-java-client/source/browse/books-cmdline-sample/src/main/java/com/google/api/services/samples/books/cmdline/BooksSample.java?repo=samples\"相对=nofollow>不使用上述code,得到同样的错误消息,谷歌图书Java示例。我也尝试禁用和重新启用的书籍API,没有任何运气。

    I've also tried to implement the Google Books Java Sample without using the code above, getting the same error message. I've also tried disabling and re-enabling the Books API, without any luck.

    先谢谢了。

    推荐答案

    这为我工作

    String link = "https://www.googleapis.com/books/v1/volumes?q="+params;
    InputStream is = null;
    try 
    {
        int timeoutConnection = 10000;
        URL url = new URL(link);
        HttpURLConnection con = (HttpURLConnection) url.openConnection();
        con.setConnectTimeout(timeoutConnection);
        con.setReadTimeout(timeoutConnection);
        con.setRequestProperty("key", "API_KEY");
        if(con.getResponseCode() != HttpURLConnection.HTTP_OK){
            publishProgress("Error conneting.");
        }
        is=con.getInputStream();
    }
    

    从这个主题:<一href=\"http://stackoverflow.com/questions/20825036/google-books-api-for-android-access-not-configured\">Google Android的书籍API - 访问未配置

    这篇关于谷歌图书API 403访问未配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆