Googleカレンダーの「マイカレンダー」に「NewCalendar」という名前のカレンダーを新規に登録しようとしてしまいますが、下記のエラーが表示され登録ができません。
The following error occurred: 403 Forbidden { "code": 403, "errors": [ { "domain": "global", "message": "Insufficient Permission", "reason": "insufficientPermissions" } ], "message": "Insufficient Permission" }
このエラーを解決してカレンダーを登録するためにはどうすればよいでしょうか?
コードはquickstart(https://developers.google.com/calendar/quickstart/android)のものに
private String createCalendar() throws IOException { com.google.api.services.calendar.model.Calendar calendar = new Calendar(); calendar.setSummary("NewCalendar"); calendar.setTimeZone("Asia/Tokyo"); Calendar createdCalendar = mService.calendars().insert(calendar).execute(); String calendarId = createdCalendar.getId(); CalendarListEntry calendarListEntry = mService.calendarList().get(calendarId).execute(); CalendarListEntry updatedCalendarListEntry = mService.calendarList() .update(calendarListEntry.getId(), calendarListEntry) .setColorRgbFormat(true) .execute(); return calendarId; }
を追加し、doInBackgroundに下記のように追記しています。
@Override protected List<String> doInBackground(Void... params) { try { createCalendar(); return getDataFromApi(); } catch (Exception e) { mLastError = e; cancel(true); return null; } }
あなたの回答
tips
プレビュー