Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final List<String> SCOPES = Arrays.asList(CalendarScopes.CALENDAR,
- CalendarScopes.CALENDAR_READONLY);
- private HttpTransport httpTransport = AndroidHttp.newCompatibleTransport();
- private JsonFactory jsonFactory = GsonFactory.getDefaultInstance();
- private GoogleAccountCredential credential;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- credential = GoogleAccountCredential.usingOAuth2(this, SCOPES);
- user = (User) getIntent().getExtras().getSerializable(User.KEY);
- credential.setSelectedAccountName(user.getEmail());
- // user.getEmail() is the value I previously retrieved from the selected
- // android.accounts.Account.name
- Calendar cal = new Calendar.Builder(httpTransport, jsonFactory, credential)
- .setApplicationName("TestApp/1.0")
- .build();
- }
- String pageToken = null;
- do {
- CalendarList calendarList = cal.calendarList()
- .list()
- .setPageToken(pageToken)
- .execute();
- calendars.addAll(calendarList.getItems());
- pageToken = calendarList.getNextPageToken();
- } while (pageToken != null);
- {
- "code": 403,
- "errors": [
- {
- "domain": "usageLimits",
- "message": "Access Not Configured. The API is not enabled for your project, or 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 configuration.",
- "reason": "accessNotConfigured",
- "extendedHelp": "https://console.developers.google.com"
- }
- ],
- "message": "Access Not Configured. The API is not enabled for your project, or 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 configuration."
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement