Google Calendar Api Android: 403 Error -


i having lot of trouble trying google calendar api work me. have searched lot , tried many solutions seem fail.

what tried: - enabling contacts api - google+ api - google calendar api - running app in debug/release mode - recreating sha1 code many, many times - changing app name

here's mainactivity, it's similar 1 in quickstart changed bit create event once done.

package com.example.roudy.calendarplayground;  public class mainactivity extends appcompatactivity  implements easypermissions.permissioncallbacks{ private googleaccountcredential mcredential;  private static final int request_account_picker = 1000; private static final int request_authorization = 1001; private static final int request_google_play_services = 1002; private static final int request_permission_get_accounts = 1003; private static final string pref_account_name = "accountname"; private static final string[] scopes = { calendarscopes.calendar };  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     mcredential = googleaccountcredential.usingoauth2(             getapplicationcontext(), arrays.aslist(scopes))             .setbackoff(new exponentialbackoff());     getresultsfromapi(); }  @override public void onpermissionsgranted(int requestcode, list<string> perms) {  }  @override public void onpermissionsdenied(int requestcode, list<string> perms) {  }  private void getresultsfromapi() {     if (!isgoogleplayservicesavailable()) {         acquiregoogleplayservices();     } else if (mcredential.getselectedaccountname() == null) {         chooseaccount();     } else if (!isdeviceonline()) {         toast.maketext(this, "no network connection available.", toast.length_short).show();     } else if (!easypermissions.haspermissions(this, manifest.permission.write_calendar)){         easypermissions.requestpermissions(                 this,                 "this app needs write calendar.",                 request_permission_get_accounts,                 manifest.permission.write_calendar);     } else if(!easypermissions.haspermissions(this, manifest.permission.read_calendar)){         easypermissions.requestpermissions(                 this,                 "this app needs read calendar.",                 request_permission_get_accounts,                 manifest.permission.read_calendar);     } else {         new createevent(mcredential).execute();     }  }  private class createevent extends asynctask<void, void, void>{     private com.google.api.services.calendar.calendar service = null;     private exception mlasterror;     public createevent (googleaccountcredential credential) {         httptransport transport = androidhttp.newcompatibletransport();         jsonfactory jsonfactory = jacksonfactory.getdefaultinstance();         service = new com.google.api.services.calendar.calendar.builder(                 transport, jsonfactory, credential)                 .setapplicationname("calendarplayground")                 .build();     }     @override     protected void doinbackground(void... voids) {         event event = new event()                 .setsummary("tutor meetting!")                 .setlocation("beirut, lebanon")                 .setdescription("some weird description!");          datetime startdatetime = new datetime("2016-08-08t17:00:00");         eventdatetime start = new eventdatetime()                 .setdatetime(startdatetime)                 .settimezone("gmt+3");         event.setstart(start);          datetime enddatetime = new datetime("2016-08-08t18:00:00");         eventdatetime end = new eventdatetime()                 .setdatetime(enddatetime)                 .settimezone("gmt+3");         event.setend(end);          eventreminder[] reminderoverrides = new eventreminder[] {                 new eventreminder().setmethod("email").setminutes(24 * 60),                 new eventreminder().setmethod("popup").setminutes(10),         };          event.reminders reminders = new event.reminders()                 .setusedefault(false)                 .setoverrides(arrays.aslist(reminderoverrides));         event.setreminders(reminders);           string calendarid = "primary";         try {            service.events().insert(calendarid, event).execute();         } catch (exception e) {             mlasterror = e;             e.printstacktrace();             cancel(true);         }         return null;     }     @override     protected void oncancelled() {         toast.maketext(mainactivity.this, "task canceled", toast.length_short).show();         if (mlasterror != null) {             if (mlasterror instanceof googleplayservicesavailabilityioexception) { // not entered                 showgoogleplayservicesavailabilityerrordialog(                         ((googleplayservicesavailabilityioexception) mlasterror)                                 .getconnectionstatuscode());             } else if (mlasterror instanceof userrecoverableauthioexception) { // not entered                 startactivityforresult(                         ((userrecoverableauthioexception) mlasterror).getintent(),                         mainactivity.request_authorization);             } else {              }         } else {          }     }      @override     protected void onpostexecute(void avoid) {         toast.maketext(mainactivity.this, "event created !", toast.length_short).show();         super.onpostexecute(avoid);     } }  @afterpermissiongranted(request_permission_get_accounts) private void chooseaccount() {     if (easypermissions.haspermissions(             this, manifest.permission.get_accounts)) {         string accountname = getpreferences(context.mode_private)                 .getstring(pref_account_name, null);         if (accountname != null) {             mcredential.setselectedaccountname(accountname);             getresultsfromapi();         } else {             startactivityforresult(                     mcredential.newchooseaccountintent(),                     request_account_picker);         }     } else {         easypermissions.requestpermissions(                 this,                 "this app needs access google account (via contacts).",                 request_permission_get_accounts,                 manifest.permission.get_accounts);     } }  @override protected void onactivityresult(         int requestcode, int resultcode, intent data) {     super.onactivityresult(requestcode, resultcode, data);     switch(requestcode) {         case request_google_play_services:             if (resultcode != result_ok) {                 toast.maketext(this, "this app requires google play services. please install " +                         "google play services on device , relaunch app.", toast.length_short).show();              } else {                 getresultsfromapi();             }             break;         case request_account_picker:             if (resultcode == result_ok && data != null &&                     data.getextras() != null) {                 string accountname =                         data.getstringextra(accountmanager.key_account_name);                 if (accountname != null) {                     sharedpreferences settings =                             getpreferences(context.mode_private);                     sharedpreferences.editor editor = settings.edit();                     editor.putstring(pref_account_name, accountname);                     editor.apply();                     mcredential.setselectedaccountname(accountname);                     getresultsfromapi();                 }             }             break;         case request_authorization:             if (resultcode == result_ok) {                 getresultsfromapi();             }             break;     } }  public void onrequestpermissionsresult(int requestcode,                                        @nonnull string[] permissions,                                        @nonnull int[] grantresults) {     super.onrequestpermissionsresult(requestcode, permissions, grantresults);     easypermissions.onrequestpermissionsresult(             requestcode, permissions, grantresults, this); } private boolean isdeviceonline() {     connectivitymanager connmgr =             (connectivitymanager) getsystemservice(context.connectivity_service);     networkinfo networkinfo = connmgr.getactivenetworkinfo();     return (networkinfo != null && networkinfo.isconnected()); }  private boolean isgoogleplayservicesavailable() {     googleapiavailability apiavailability =             googleapiavailability.getinstance();     final int connectionstatuscode =             apiavailability.isgoogleplayservicesavailable(this);     return connectionstatuscode == connectionresult.success; }  private void acquiregoogleplayservices() {     googleapiavailability apiavailability =             googleapiavailability.getinstance();     final int connectionstatuscode =             apiavailability.isgoogleplayservicesavailable(this);     if (apiavailability.isuserresolvableerror(connectionstatuscode)) {         showgoogleplayservicesavailabilityerrordialog(connectionstatuscode);     } }  private void showgoogleplayservicesavailabilityerrordialog(         final int connectionstatuscode) {     googleapiavailability apiavailability = googleapiavailability.getinstance();     dialog dialog = apiavailability.geterrordialog(             mainactivity.this,             connectionstatuscode,             request_google_play_services);     dialog.show(); }      } 

below error i'm getting. have made sure should before asking question , searched answers everywhere , nothing seem have worked. "cancel(true)" of course triggered none of if conditions entered, btw. ( see code )

    w/system.err: { w/system.err:   "code" : 403, w/system.err:   "errors" : [ { w/system.err:     "domain" : "usagelimits", w/system.err:     "message" : "access not configured. calendar api has not been used in project 608941808256 before or disabled. enable visiting https://console.developers.google.com/apis/api/calendar/overview?project=608941808256 retry. if enabled api recently, wait few minutes action propagate our systems , retry.", w/system.err:     "reason" : "accessnotconfigured", w/system.err:     "extendedhelp" : "https://console.developers.google.com/apis/api/calendar/overview?project=608941808256" w/system.err:   } ], w/system.err:   "message" : "access not configured. calendar api has not been used in project 608941808256 before or disabled. enable visiting https://console.developers.google.com/apis/api/calendar/overview?project=608941808256 retry. if enabled api recently, wait few minutes action propagate our systems , retry." w/system.err: } 

i have tried recreating sha1 many, many times

package name copy pasted , looks same

since error can report project #, means have entered sha-1 , api key properly. has issue in google dev console.

here's need do:

log in > library > google calendar api

on screen should able enable api of api keys. once click enable, continue credentials page.

create credentials > me choose

once there enter api using , using it. in case google calendar api , android. once enter that, dev console should create 0auth 2.0 credentials google users can log in , use google calendar api in app. hope helps!


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -