public ActionResult Google() { if (googleClient == null) { // access Google Calendar API to force initial authentication googleClient = new GoogleClient(); } if (HttpContext.Request["code"] != null) { // load access tokens googleClient.Authenticator.LoadAccessToken(); } try { // force authentication by accessing calendar settings googleClient.ForceAuthentication(); return(RedirectToAction("Home", "Dashboard", new { consentStatus = UserDataModel.GoogleConsentSuccess })); } catch (ThreadAbortException) { throw; } catch (Exception) { return(RedirectToAction("Home", "Dashboard", new { consentStatus = UserDataModel.GoogleConsentFail })); } }
// entry point to verify Google consent it working public ActionResult AccessGoogle() { GoogleClient client = new GoogleClient(this.CurrentUser, this.StorageContext); client.ForceAuthentication(); return(RedirectToAction("Home", "Dashboard")); }