执行Android Google日历快速入门时出现403 Forbidden Error

时间:2015-08-05 22:45:43

标签: android api calendar

我正在尝试使用我的应用添加Google日历集成。我在此处跟随了Android快速入门指南https://developers.google.com/google-apps/calendar/quickstart/android

我在将此集成到现有项目时遇到了问题,因此我尝试制作一个新项目并复制并粘贴代码。但是,我仍然收到此错误:

403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured. The API (Calendar API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",
"reason": "accessNotConfigured",
"extendedHelp": "https://console.developers.google.com"
}
],
"message": "Access Not Configured. The API (Calendar API) is not enabled for your project. Please use the Google Developers Console to update your configuration."
}
        at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
        at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1056)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
        at com.gdosheriii.android.calendartest.ApiAsyncTask.getDataFromApi(ApiAsyncTask.java:72)
        at com.gdosheriii.android.calendartest.ApiAsyncTask.doInBackground(ApiAsyncTask.java:39)
        at com.gdosheriii.android.calendartest.ApiAsyncTask.doInBackground(ApiAsyncTask.java:19)
        at android.os.AsyncTask$2.call(AsyncTask.java:288)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:841)

我做错了什么?在过去的两个小时里,我一直在谷歌搜索答案,但似乎没有什么可以解决的。是的,我确实在Google Developers Console中创建了一个客户端ID。我复制并粘贴了包(com.gdosheriii.android.calendartest)和SHA1密钥。我启用了Calendar API。

这样做的正确方法是什么?

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

您需要在code de google quistart中更改应用程序名称,您可以按照以下步骤执行此操作:

private class MakeRequestTask extends AsyncTask<Void, Void, List<String>> {
    private com.google.api.services.calendar.Calendar mService = null;
    private Exception mLastError = null;

    public MakeRequestTask(GoogleAccountCredential credential) {
        HttpTransport transport = AndroidHttp.newCompatibleTransport();
        JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
        mService = new com.google.api.services.calendar.Calendar.Builder(
                transport, jsonFactory, credential)
                .setApplicationName("YOUR APPLICATION NAME IN GOOGLE CONSOLE")
                .build();
    }

enter image description here