Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. private static final List<String> SCOPES = Arrays.asList(CalendarScopes.CALENDAR,
  2. CalendarScopes.CALENDAR_READONLY);
  3.  
  4.  
  5. private HttpTransport httpTransport = AndroidHttp.newCompatibleTransport();
  6. private JsonFactory jsonFactory = GsonFactory.getDefaultInstance();
  7. private GoogleAccountCredential credential;
  8.  
  9. @Override
  10. protected void onCreate(Bundle savedInstanceState) {
  11. credential = GoogleAccountCredential.usingOAuth2(this, SCOPES);
  12. user = (User) getIntent().getExtras().getSerializable(User.KEY);
  13. credential.setSelectedAccountName(user.getEmail());
  14. // user.getEmail() is the value I previously retrieved from the selected
  15. // android.accounts.Account.name
  16.  
  17. Calendar cal = new Calendar.Builder(httpTransport, jsonFactory, credential)
  18. .setApplicationName("TestApp/1.0")
  19. .build();
  20. }
  21.  
  22. String pageToken = null;
  23. do {
  24. CalendarList calendarList = cal.calendarList()
  25. .list()
  26. .setPageToken(pageToken)
  27. .execute();
  28. calendars.addAll(calendarList.getItems());
  29. pageToken = calendarList.getNextPageToken();
  30. } while (pageToken != null);
  31.  
  32. {
  33. "code": 403,
  34. "errors": [
  35. {
  36. "domain": "usageLimits",
  37. "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.",
  38. "reason": "accessNotConfigured",
  39. "extendedHelp": "https://console.developers.google.com"
  40. }
  41. ],
  42. "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."
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement