Skip to content

Commit

Permalink
v2.6.1
Browse files Browse the repository at this point in the history
If GAL blocked by corporate policy, remove OGCS features in order that basic sync works.
Only access GAL on start-up if user requested sync of meeting attendees (which can trigger Outlook security pop-up).
Code refactor into new Authenticator class.
Google authentication no longer needs manual copy+paste of code.
GoogleAuthorizationCode form removed.
Replaced deprecated method to retrieve email address from authenticator's account.
Removed CodePlex to Squirrel migration code.
Update Google Auth libraries to v1.6.0
Update Google Calendar library to v1.5.0.55
  • Loading branch information
phw198 committed Aug 23, 2017
1 parent b10cdb2 commit 8e71b1c
Show file tree
Hide file tree
Showing 55 changed files with 44,047 additions and 5,952 deletions.
15 changes: 15 additions & 0 deletions docs/Release Notes.md
@@ -1,6 +1,21 @@
| Release Notes |
|:---|

# v2.6.1.0 - Alpha

:spiral_notepad: This release will require you to reauthorise OGCS to make changes to your Google calendar.

**Enhancements**
- If Outlook address book (GAL) blocked by corporate policy, remove OGCS features in order that basic sync works.
- Only access GAL on start-up if user requested sync of meeting attendees (which can trigger Outlook security pop-up).
- Code refactor into new Authenticator class.
- Google authentication no longer needs manual copy+paste of code.
- GoogleAuthorizationCode form removed.
- Replaced deprecated method to retrieve email address from authenticator's account.
- Removed CodePlex to Squirrel migration code.
- Update Google Auth libraries to v1.6.0
- Update Google Calendar library to v1.5.0.55

# v2.6.0.0 - Beta

:boom: This release completes the migration to GitHub.
Expand Down
6 changes: 1 addition & 5 deletions docs/keyring.md
@@ -1,11 +1,7 @@
| Type | Project Name| Project ID | Status | ID | Key |
|:---|:---|:---|:---|:---|:---|
|Standard|OGCS PW 001|ogcs-pw-001|ACTIVE|369604143902-tiamt3emr8dq2q6dchqdhajmsri0fh0h.apps.googleusercontent.com|PK48M3GVypq3KSzFnB6eJHH_|
|Standard|OGCS Default|outlook-google-calendar-sync|ACTIVE|653617509806-2nq341ol8ejgqhh2ku4j45m7q2bgdimv.apps.googleusercontent.com|tAi-gZLWtasS58i8CcCwVwsq|
|Standard|OGCS Default|outlook-google-calendar-sync|ACTIVE|653617509806-2nq341ol8ejgqhh2ku4j45m7q2bgdimv.apps.googleusercontent.com|tAi-gZLWtasS58i8CcCwVwsq|
|Standard|OGCS Default|outlook-google-calendar-sync|ACTIVE|653617509806-2nq341ol8ejgqhh2ku4j45m7q2bgdimv.apps.googleusercontent.com|tAi-gZLWtasS58i8CcCwVwsq|
|Standard|OGCS Default|outlook-google-calendar-sync|ACTIVE|653617509806-2nq341ol8ejgqhh2ku4j45m7q2bgdimv.apps.googleusercontent.com|tAi-gZLWtasS58i8CcCwVwsq|
|Standard|OGCS Default|outlook-google-calendar-sync|ACTIVE|653617509806-2nq341ol8ejgqhh2ku4j45m7q2bgdimv.apps.googleusercontent.com|tAi-gZLWtasS58i8CcCwVwsq|
|Standard|OGCS PW 001|ogcs-pw-001|DISABLED|369604143902-tiamt3emr8dq2q6dchqdhajmsri0fh0h.apps.googleusercontent.com|PK48M3GVypq3KSzFnB6eJHH_|
|Standard|OGCS KW 001|ogcs-kw-001|DISABLED|110989233159-nu3ohp5otqmjq1afvkg9hkrubbgal4n4.apps.googleusercontent.com|kA4LS1BDQdhE7Xtf5xj2S0LP|

### Status
Expand Down
2 changes: 1 addition & 1 deletion docs/latest_zip_release.md
@@ -1,3 +1,3 @@
# Latest ZIP Release
**Alpha**: [v2.6.0.0](https://github.com/phw198/OutlookGoogleCalendarSync/releases/latest)
**Alpha**: [v2.6.1.0](https://github.com/phw198/OutlookGoogleCalendarSync/releases/latest)
**Beta**: [v2.6.0.0](https://github.com/phw198/OutlookGoogleCalendarSync/releases/tag/v2.6.0-beta)
6 changes: 6 additions & 0 deletions nuget-build.bat
@@ -0,0 +1,6 @@
cd src
..\nuget.exe pack OutlookGoogleCalendarSync\OutlookGoogleCalendarSync.nuspec

REM In VS Package Manager
REM PM> Install-Package squirrel.windows -Version 1.6.0
REM PM> packages\squirrel.windows.1.6.0\tools\Squirrel --releasify OutlookGoogleCalendarSync.2.6.1-alpha.nupkg --no-msi --loadingGif=..\docs\images\ogcs128x128-animated.gif
Binary file added nuget.exe
Binary file not shown.
86 changes: 26 additions & 60 deletions src/OutlookGoogleCalendarSync/Exception.cs
@@ -1,10 +1,7 @@
using log4net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OutlookGoogleCalendarSync {
class UserCancelledSyncException : Exception {
Expand All @@ -17,9 +14,9 @@ class OGCSexception {
private static readonly ILog log = LogManager.GetLogger(typeof(OGCSexception));

public static void Analyse(System.Exception ex, Boolean includeStackTrace = false) {
log.Error(ex.GetType().FullName +": "+ ex.Message);
log.Error(ex.GetType().FullName + ": " + ex.Message);
int errorCode = getErrorCode(ex);
log.Error("Code: 0x" + errorCode.ToString("X8") +";"+ errorCode.ToString());
log.Error("Code: 0x" + errorCode.ToString("X8") + ";" + errorCode.ToString());
if (includeStackTrace) log.Error(ex.StackTrace);
}

Expand Down Expand Up @@ -48,69 +45,38 @@ class OGCSexception {
return -1;
}

#region DotNet Exceptions
public static void AnalyseDotNetOpenAuth(DotNetOpenAuth.Messaging.ProtocolException ex) {
Dictionary<String, String> errors = null;
String webExceptionStr_orig = "";
System.Net.WebException webException = null;
//Process exact error
try {
webException = ex.InnerException as System.Net.WebException;
webExceptionStr_orig = extractResponseString(webException);
} catch (System.Exception subEx) {
log.Error("Failed to retrieve WebException: " + subEx.Message);
log.Debug(ex.Message);
throw ex;
}
if (string.IsNullOrEmpty(webExceptionStr_orig)) {
//Not an OAuthErrorMsg
log.Error(webException.Message);
throw ex;
}
try {
/* Could treat this properly with JSON but would be another dll just to handle this situation.
* OAuthErrorMsg error =
* JsonConvert.DeserializeObject<OAuthErrorMsg>(ExtractResponseString(webException));
* var errorMessage = error.error_description;
*/
//String webExceptionStr = "{\n \"error\" : \"invalid_client\",\n \"error_description\" : \"The OAuth client was not found.\"\n}";
String webExceptionStr = webExceptionStr_orig.Replace("\"", "");
webExceptionStr = webExceptionStr.TrimStart('{'); webExceptionStr = webExceptionStr.TrimEnd('}');
errors = webExceptionStr.Split(new String[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Split(':')).ToDictionary(x => x[0].Trim(), x => x[1].Trim().TrimEnd(','));
public static void AnalyseAggregate(AggregateException agex, Boolean throwError = true) {
foreach (System.Exception ex in agex.InnerExceptions) {
if (ex is ApplicationException) {
if (!String.IsNullOrEmpty(ex.Message)) MainForm.Instance.Logboxout(ex.Message);
else log.Error(ex.Message);

} catch (System.Exception subEx) {
log.Error("Failed to process exact WebException: " + subEx.Message);
log.Debug(webExceptionStr_orig);
throw ex;
}
} else if (ex is Google.Apis.Auth.OAuth2.Responses.TokenResponseException) {
AnalyseTokenResponse(ex as Google.Apis.Auth.OAuth2.Responses.TokenResponseException, throwError);

if (errors.ContainsKey("error")) {
String instructions = "On the Settings > Google tab, please disconnect and re-authenticate your account.";
if ("invalid_client;unauthorized_client".Contains(errors["error"]))
throw new System.Exception("Invalid authentication token. Account requires reauthorising.\r\n" + instructions, ex);
else if (errors["error"] == "invalid_grant")
throw new System.Exception("Google has revoked your authentication token. Account requires reauthorising.\r\n" + instructions, ex);
} else Analyse(ex);
}
log.Debug("Unknown web exception.");
throw ex;
}

private static String extractResponseString(System.Net.WebException webException) {
if (webException == null || webException.Response == null)
return null;
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.";

var responseStream =
webException.Response.GetResponseStream() as MemoryStream;
log.Warn("Token response error: " + ex.Message);
if (ex.Error.Error == "access_denied") {
MainForm.Instance.AsyncLogboxout("Failed to obtain Calendar access from Google - it's possible your access has been revoked.\r\n" + instructions, true);

if (responseStream == null)
return null;
} else if ("invalid_client;unauthorized_client".Contains(ex.Error.Error))
MainForm.Instance.AsyncLogboxout("Invalid authentication token. Account requires reauthorising.\r\n" + instructions, true);

var responseBytes = responseStream.ToArray();
else if (ex.Error.Error == "invalid_grant")
MainForm.Instance.AsyncLogboxout("Google has revoked your authentication token. Account requires reauthorising.\r\n" + instructions, true);

var responseString = Encoding.UTF8.GetString(responseBytes);
return responseString;
else {
log.Warn("Unknown web exception.");
MainForm.Instance.AsyncLogboxout("Unable to communicate with Google. The following error occurred:");
MainForm.Instance.AsyncLogboxout(ex.Message);
}
if (throwError) throw ex;
}
#endregion
}
}
233 changes: 0 additions & 233 deletions src/OutlookGoogleCalendarSync/GoogleAuthorizationCode.Designer.cs

This file was deleted.

0 comments on commit 8e71b1c

Please sign in to comment.