tenseleyflow/rcal / cd903a9

Browse files

Embed official Google OAuth client

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
cd903a91cd4505dff014c8ee0a7e642903526163
Parents
18935ad
Tree
5ad6e3c

3 changed files

StatusFile+-
M README.md 3 3
M src/config.rs 30 0
M src/providers.rs 3 2
README.mdmodified
@@ -268,9 +268,9 @@ Calendar. Provider reminders fire from cached Google events after a sync.
268
 - CalDAV and other non-Microsoft/non-Google providers are not implemented yet.
268
 - CalDAV and other non-Microsoft/non-Google providers are not implemented yet.
269
 - Provider sync is manual and cache-first; there is no background provider
269
 - Provider sync is manual and cache-first; there is no background provider
270
   sync daemon yet.
270
   sync daemon yet.
271
-- Google official OAuth client registration and verification are still in
271
+- Google OAuth verification may still be in progress for early releases. If the
272
-  progress; until those constants are filled for a release build, use the
272
+  official client flow is unavailable in a custom build, use the advanced
273
-  advanced custom-client setup above.
273
+  custom-client setup above.
274
 
274
 
275
 ## Development
275
 ## Development
276
 
276
 
src/config.rsmodified
@@ -1030,6 +1030,36 @@ calendars = ["cal-1"]
1030
         assert_eq!(account.tenant, MICROSOFT_DEFAULT_TENANT);
1030
         assert_eq!(account.tenant, MICROSOFT_DEFAULT_TENANT);
1031
     }
1031
     }
1032
 
1032
 
1033
+    #[test]
1034
+    fn google_provider_defaults_to_official_desktop_client() {
1035
+        let path = temp_config_path("google-providers-official/config.toml");
1036
+        let _ = fs::remove_dir_all(path.parent().and_then(Path::parent).expect("test root"));
1037
+        fs::create_dir_all(path.parent().expect("config dir")).expect("dir creates");
1038
+        fs::write(
1039
+            &path,
1040
+            r#"
1041
+[providers.google]
1042
+enabled = true
1043
+default_account = "personal"
1044
+default_calendar = "primary"
1045
+
1046
+[[providers.google.accounts]]
1047
+id = "personal"
1048
+calendars = ["primary"]
1049
+"#,
1050
+        )
1051
+        .expect("config writes");
1052
+
1053
+        let config = load_config_file(&path).expect("config loads");
1054
+        let _ = fs::remove_dir_all(path.parent().and_then(Path::parent).expect("test root"));
1055
+
1056
+        let account = &config.providers.google.accounts[0];
1057
+        let (official_client_id, official_client_secret) =
1058
+            google_official_client_config().expect("official Google client exists");
1059
+        assert_eq!(account.client_id, official_client_id);
1060
+        assert_eq!(account.client_secret, official_client_secret);
1061
+    }
1062
+
1033
     #[test]
1063
     #[test]
1034
     fn google_provider_config_parses_and_resolves_paths() {
1064
     fn google_provider_config_parses_and_resolves_paths() {
1035
         let path = temp_config_path("google-providers/config.toml");
1065
         let path = temp_config_path("google-providers/config.toml");
src/providers.rsmodified
@@ -44,8 +44,9 @@ const GOOGLE_SCOPES: &str = concat!(
44
 const GOOGLE_KEYRING_SERVICE: &str = "rcal.google";
44
 const GOOGLE_KEYRING_SERVICE: &str = "rcal.google";
45
 pub const MICROSOFT_OFFICIAL_CLIENT_ID: &str = "9a49eaac-422b-4192-a65d-82dc8f43c11d";
45
 pub const MICROSOFT_OFFICIAL_CLIENT_ID: &str = "9a49eaac-422b-4192-a65d-82dc8f43c11d";
46
 pub const MICROSOFT_DEFAULT_TENANT: &str = "common";
46
 pub const MICROSOFT_DEFAULT_TENANT: &str = "common";
47
-pub const GOOGLE_OFFICIAL_CLIENT_ID: &str = "";
47
+pub const GOOGLE_OFFICIAL_CLIENT_ID: &str =
48
-pub const GOOGLE_OFFICIAL_CLIENT_SECRET: &str = "";
48
+    "1074776721941-d1paj4fnnn77bd3rrcliodhoveafbise.apps.googleusercontent.com";
49
+pub const GOOGLE_OFFICIAL_CLIENT_SECRET: &str = "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";
49
 
50
 
50
 #[derive(Debug, Clone, PartialEq, Eq)]
51
 #[derive(Debug, Clone, PartialEq, Eq)]
51
 pub struct ProviderConfig {
52
 pub struct ProviderConfig {