示例#1
0
        public static void AnalyseTokenResponse(Google.Apis.Auth.OAuth2.Responses.TokenResponseException ex, Boolean throwError = true)
        {
            String instructions = "On the Settings > Google tab, please disconnect and re-authenticate your account.";

            log.Warn("Token response error: " + ex.Message);
            if (ex.Error.Error == "access_denied")
            {
                MainForm.Instance.Console.Update("Failed to obtain Calendar access from Google - it's possible your access has been revoked.<br/>" + instructions, Console.Markup.error, notifyBubble: true);
            }

            else if ("invalid_client;unauthorized_client".Contains(ex.Error.Error))
            {
                MainForm.Instance.Console.Update("Invalid authentication token. Account requires reauthorising.\r\n" + instructions, Console.Markup.error, notifyBubble: true);
            }

            else if (ex.Error.Error == "invalid_grant")
            {
                MainForm.Instance.Console.Update("Google has revoked your authentication token. Account requires reauthorising.<br/>" + instructions, Console.Markup.error, notifyBubble: true);
            }

            else
            {
                log.Warn("Unknown web exception.");
                MainForm.Instance.Console.Update("Unable to communicate with Google. The following error occurred:<br/>" + ex.Message, Console.Markup.error, notifyBubble: true);
            }
            if (throwError)
            {
                throw ex;
            }
        }
示例#2
0
 /// <summary>Capture this exception as log4net FAIL (not ERROR) when logged</summary>
 public static void LogAsFail(ref Google.Apis.Auth.OAuth2.Responses.TokenResponseException ex)
 {
     if (ex.Data.Contains(LogAs))
     {
         ex.Data[LogAs] = OGCSexception.LogLevel.FAIL;
     }
     else
     {
         ex.Data.Add(LogAs, OGCSexception.LogLevel.FAIL);
     }
 }