Bläddra i källkod

Switch OAuth defaults to Classroom project credentials.

Point bundled Google OAuth client values to the Classroom project and clear legacy Meeting-app UserDefaults overrides so sign-in consistently uses Classroom branding and APIs.

Made-with: Cursor
huzaifahayat12 1 vecka sedan
förälder
incheckning
2831edc1c8
1 ändrade filer med 15 tillägg och 3 borttagningar
  1. 15 3
      classroom_app/Auth/GoogleOAuthService.swift

+ 15 - 3
classroom_app/Auth/GoogleOAuthService.swift

@@ -35,8 +35,9 @@ final class GoogleOAuthService: NSObject {
35 35
     // Put your OAuth Desktop client ID here (from Google Cloud Console).
36 36
     private let clientIdDefaultsKey = "google.oauth.clientId"
37 37
     private let clientSecretDefaultsKey = "google.oauth.clientSecret"
38
-    private let bundledClientId = "824412072260-m9g5g6mlemnb0o079rtuqnh0e1unmelc.apps.googleusercontent.com"
39
-    private let bundledClientSecret = "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"
38
+    private let bundledClientId = "1027920783127-tu96fn69edr6fimn32nqh9rfj711fm2i.apps.googleusercontent.com"
39
+    private let bundledClientSecret = "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"
40
+    private let legacyMeetingClientId = "824412072260-m9g5g6mlemnb0o079rtuqnh0e1unmelc.apps.googleusercontent.com"
40 41
 
41 42
     // Calendar is needed for schedule. Profile/email make login feel complete in-app.
42 43
     private let scopes = [
@@ -50,7 +51,10 @@ final class GoogleOAuthService: NSObject {
50 51
     ]
51 52
 
52 53
     private let tokenStore = KeychainTokenStore()
53
-    private override init() {}
54
+    private override init() {
55
+        super.init()
56
+        migrateLegacyOAuthOverridesIfNeeded()
57
+    }
54 58
 
55 59
     func configuredClientId() -> String? {
56 60
         let value = UserDefaults.standard.string(forKey: clientIdDefaultsKey)?.trimmingCharacters(in: .whitespacesAndNewlines)
@@ -72,6 +76,14 @@ final class GoogleOAuthService: NSObject {
72 76
         UserDefaults.standard.set(clientSecret, forKey: clientSecretDefaultsKey)
73 77
     }
74 78
 
79
+    private func migrateLegacyOAuthOverridesIfNeeded() {
80
+        let configuredId = UserDefaults.standard.string(forKey: clientIdDefaultsKey)?.trimmingCharacters(in: .whitespacesAndNewlines)
81
+        guard configuredId == legacyMeetingClientId else { return }
82
+        // Remove old project override so this app uses the Classroom OAuth client.
83
+        UserDefaults.standard.removeObject(forKey: clientIdDefaultsKey)
84
+        UserDefaults.standard.removeObject(forKey: clientSecretDefaultsKey)
85
+    }
86
+
75 87
     func signOut() throws {
76 88
         try tokenStore.deleteTokens()
77 89
     }