Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit fab4ba2

Browse files
authored
Merge pull request #610 from wordpress-mobile/issue/609-googlesignin-v6
Update GoogleSignIn to 6.0.1
2 parents 8b6460a + 8966df5 commit fab4ba2

File tree

7 files changed

+44
-95
lines changed

7 files changed

+44
-95
lines changed

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def wordpress_authenticator_pods
2222
pod '1PasswordExtension', '1.8.6'
2323
pod 'Alamofire', '4.8'
2424
pod 'CocoaLumberjack', '3.5.2'
25-
pod 'GoogleSignIn', '5.0.2'
25+
pod 'GoogleSignIn', '6.0.1'
2626
pod 'lottie-ios', '3.1.6'
2727
pod 'NSURL+IDN', '0.4'
2828
pod 'SVProgressHUD', '2.2.5'

Podfile.lock

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
PODS:
22
- 1PasswordExtension (1.8.6)
33
- Alamofire (4.8.0)
4-
- AppAuth (1.3.0):
5-
- AppAuth/Core (= 1.3.0)
6-
- AppAuth/ExternalUserAgent (= 1.3.0)
7-
- AppAuth/Core (1.3.0)
8-
- AppAuth/ExternalUserAgent (1.3.0)
4+
- AppAuth (1.4.0):
5+
- AppAuth/Core (= 1.4.0)
6+
- AppAuth/ExternalUserAgent (= 1.4.0)
7+
- AppAuth/Core (1.4.0)
8+
- AppAuth/ExternalUserAgent (1.4.0)
99
- CocoaLumberjack (3.5.2):
1010
- CocoaLumberjack/Core (= 3.5.2)
1111
- CocoaLumberjack/Core (3.5.2)
1212
- Expecta (1.0.6)
1313
- FormatterKit/Resources (1.8.2)
1414
- FormatterKit/TimeIntervalFormatter (1.8.2):
1515
- FormatterKit/Resources
16-
- GoogleSignIn (5.0.2):
17-
- AppAuth (~> 1.2)
16+
- GoogleSignIn (6.0.1):
17+
- AppAuth (~> 1.4)
1818
- GTMAppAuth (~> 1.0)
1919
- GTMSessionFetcher/Core (~> 1.1)
2020
- Gridicons (1.0.1)
21-
- GTMAppAuth (1.0.0):
22-
- AppAuth/Core (~> 1.0)
23-
- GTMSessionFetcher (~> 1.1)
24-
- GTMSessionFetcher (1.4.0):
25-
- GTMSessionFetcher/Full (= 1.4.0)
26-
- GTMSessionFetcher/Core (1.4.0)
27-
- GTMSessionFetcher/Full (1.4.0):
28-
- GTMSessionFetcher/Core (= 1.4.0)
21+
- GTMAppAuth (1.2.2):
22+
- AppAuth/Core (~> 1.4)
23+
- GTMSessionFetcher/Core (~> 1.5)
24+
- GTMSessionFetcher/Core (1.6.1)
2925
- lottie-ios (3.1.6)
3026
- NSObject-SafeExpectations (0.0.4)
3127
- "NSURL+IDN (0.4)"
@@ -66,7 +62,7 @@ DEPENDENCIES:
6662
- Alamofire (= 4.8)
6763
- CocoaLumberjack (= 3.5.2)
6864
- Expecta (= 1.0.6)
69-
- GoogleSignIn (= 5.0.2)
65+
- GoogleSignIn (= 6.0.1)
7066
- Gridicons (~> 1.0-beta)
7167
- lottie-ios (= 3.1.6)
7268
- "NSURL+IDN (= 0.4)"
@@ -107,14 +103,14 @@ SPEC REPOS:
107103
SPEC CHECKSUMS:
108104
1PasswordExtension: f97cc80ae58053c331b2b6dc8843ba7103b33794
109105
Alamofire: 3ec537f71edc9804815215393ae2b1a8ea33a844
110-
AppAuth: 73574f3013a1e65b9601a3ddc8b3158cce68c09d
106+
AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7
111107
CocoaLumberjack: 118bf4a820efc641f79fa487b75ed928dccfae23
112108
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
113109
FormatterKit: 4b8f29acc9b872d5d12a63efb560661e8f2e1b98
114-
GoogleSignIn: 7137d297ddc022a7e0aa4619c86d72c909fa7213
110+
GoogleSignIn: 1b0c4ec33a6fe282f4fa35d8ac64263230ddaf36
115111
Gridicons: 8e19276b20bb15d1fda1d4d0db96d066d170135b
116-
GTMAppAuth: 4deac854479704f348309e7b66189e604cf5e01e
117-
GTMSessionFetcher: 6f5c8abbab8a9bce4bb3f057e317728ec6182b10
112+
GTMAppAuth: ad5c2b70b9a8689e1a04033c9369c4915bfcbe89
113+
GTMSessionFetcher: 36689134877faeb055b27dfa4ccc9ceaa42e029e
118114
lottie-ios: 85ce835dd8c53e02509f20729fc7d6a4e6645a0a
119115
NSObject-SafeExpectations: ab8fe623d36b25aa1f150affa324e40a2f3c0374
120116
"NSURL+IDN": afc873e639c18138a1589697c3add197fe8679ca
@@ -128,6 +124,6 @@ SPEC CHECKSUMS:
128124
WordPressUI: 1cf47a3b78154faf69caa18569ee7ece1e510fa0
129125
wpxmlrpc: bf55a43a7e710bd2a4fb8c02dfe83b1246f14f13
130126

131-
PODFILE CHECKSUM: a6d2af0a12a196a91634fccfc78a369b39e2be2b
127+
PODFILE CHECKSUM: 8cba285326010a5f8e3da755a3a83ec7643e858c
132128

133129
COCOAPODS: 1.10.0

WordPressAuthenticator.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressAuthenticator"
3-
s.version = "1.41.0-beta.1"
3+
s.version = "1.41.0-beta.2"
44

55
s.summary = 'WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps.'
66
s.description = <<-DESC
@@ -43,7 +43,7 @@ Pod::Spec.new do |s|
4343
s.dependency 'NSURL+IDN', '0.4'
4444
s.dependency 'SVProgressHUD', '~> 2.2.5'
4545
s.dependency 'Gridicons', '~> 1.0'
46-
s.dependency 'GoogleSignIn', '~> 5.0.2'
46+
s.dependency 'GoogleSignIn', '~> 6.0.1'
4747

4848
# Use a loose restriction that allows both production and beta versions, up to the next major version.
4949
# If you want to update which of these is used, specify it in the host app.

WordPressAuthenticator.xcodeproj/project.pbxproj

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,6 @@
984984
B5ED78F1207E976500A8FD8C /* Headers */,
985985
B5ED78F2207E976500A8FD8C /* Resources */,
986986
B5A5274B20B479D30065BE81 /* CopyFiles */,
987-
5ABD4390CE7F425565FA9BD2 /* [CP] Copy Pods Resources */,
988987
);
989988
buildRules = (
990989
);
@@ -1004,7 +1003,6 @@
10041003
B5ED78FA207E976500A8FD8C /* Frameworks */,
10051004
B5ED78FB207E976500A8FD8C /* Resources */,
10061005
E708E1947D7E55D6347CD251 /* [CP] Embed Pods Frameworks */,
1007-
557F1B615C0496D7C3F3DDAB /* [CP] Copy Pods Resources */,
10081006
);
10091007
buildRules = (
10101008
);
@@ -1097,42 +1095,6 @@
10971095
/* End PBXResourcesBuildPhase section */
10981096

10991097
/* Begin PBXShellScriptBuildPhase section */
1100-
557F1B615C0496D7C3F3DDAB /* [CP] Copy Pods Resources */ = {
1101-
isa = PBXShellScriptBuildPhase;
1102-
buildActionMask = 2147483647;
1103-
files = (
1104-
);
1105-
inputPaths = (
1106-
"${PODS_ROOT}/Target Support Files/Pods-WordPressAuthenticatorTests/Pods-WordPressAuthenticatorTests-resources.sh",
1107-
"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
1108-
);
1109-
name = "[CP] Copy Pods Resources";
1110-
outputPaths = (
1111-
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
1112-
);
1113-
runOnlyForDeploymentPostprocessing = 0;
1114-
shellPath = /bin/sh;
1115-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-WordPressAuthenticatorTests/Pods-WordPressAuthenticatorTests-resources.sh\"\n";
1116-
showEnvVarsInLog = 0;
1117-
};
1118-
5ABD4390CE7F425565FA9BD2 /* [CP] Copy Pods Resources */ = {
1119-
isa = PBXShellScriptBuildPhase;
1120-
buildActionMask = 2147483647;
1121-
files = (
1122-
);
1123-
inputPaths = (
1124-
"${PODS_ROOT}/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator-resources.sh",
1125-
"${PODS_ROOT}/GoogleSignIn/Resources/GoogleSignIn.bundle",
1126-
);
1127-
name = "[CP] Copy Pods Resources";
1128-
outputPaths = (
1129-
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
1130-
);
1131-
runOnlyForDeploymentPostprocessing = 0;
1132-
shellPath = /bin/sh;
1133-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator-resources.sh\"\n";
1134-
showEnvVarsInLog = 0;
1135-
};
11361098
6CD6648B820552D8638F8EDA /* [CP] Check Pods Manifest.lock */ = {
11371099
isa = PBXShellScriptBuildPhase;
11381100
buildActionMask = 2147483647;
@@ -1183,6 +1145,7 @@
11831145
"${BUILT_PRODUCTS_DIR}/FormatterKit/FormatterKit.framework",
11841146
"${BUILT_PRODUCTS_DIR}/GTMAppAuth/GTMAppAuth.framework",
11851147
"${BUILT_PRODUCTS_DIR}/GTMSessionFetcher/GTMSessionFetcher.framework",
1148+
"${BUILT_PRODUCTS_DIR}/GoogleSignIn/GoogleSignIn.framework",
11861149
"${BUILT_PRODUCTS_DIR}/Gridicons/Gridicons.framework",
11871150
"${BUILT_PRODUCTS_DIR}/NSObject-SafeExpectations/NSObject_SafeExpectations.framework",
11881151
"${BUILT_PRODUCTS_DIR}/NSURL+IDN/NSURL_IDN.framework",
@@ -1207,6 +1170,7 @@
12071170
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FormatterKit.framework",
12081171
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMAppAuth.framework",
12091172
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMSessionFetcher.framework",
1173+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleSignIn.framework",
12101174
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Gridicons.framework",
12111175
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NSObject_SafeExpectations.framework",
12121176
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NSURL_IDN.framework",

WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ import WordPressKit
129129
/// Attempts to process the specified URL as a Google Authentication Link. Returns *true* on success.
130130
///
131131
@objc public func handleGoogleAuthUrl(_ url: URL, sourceApplication: String?, annotation: Any?) -> Bool {
132-
return GIDSignIn.sharedInstance().handle(url)
132+
return GIDSignIn.sharedInstance.handle(url)
133133
}
134134

135135
/// Attempts to process the specified URL as a WordPress Authentication Link. Returns *true* on success.

WordPressAuthenticator/Signin/Login2FAViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF
170170
syncWPComAndPresentEpilogue(credentials: credentials)
171171

172172
// Disconnect now that we're done with Google.
173-
GIDSignIn.sharedInstance().disconnect()
173+
GIDSignIn.sharedInstance.disconnect()
174174

175175
// This stat is part of a funnel that provides critical information. Please
176176
// consult with your lead before removing this event.

WordPressAuthenticator/Unified Auth/GoogleAuthenticator.swift

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,16 @@ private extension GoogleAuthenticator {
164164
track(.createAccountInitiated)
165165
}
166166

167-
guard let googleInstance = GIDSignIn.sharedInstance() else {
168-
DDLogError("GoogleAuthenticator: Failed to get `GIDSignIn.sharedInstance()`.")
169-
return
170-
}
167+
let googleInstance = GIDSignIn.sharedInstance
168+
let configuration = GIDConfiguration(clientID: authConfig.googleLoginClientId, serverClientID: authConfig.googleLoginServerClientId)
171169

172170
googleInstance.disconnect()
173171

174-
// This has no effect since we don't use Google UI, but presentingViewController is required, so here we are.
175-
googleInstance.presentingViewController = viewController
176-
177-
googleInstance.delegate = self
178-
googleInstance.clientID = authConfig.googleLoginClientId
179-
googleInstance.serverClientID = authConfig.googleLoginServerClientId
180-
181172
// Start the Google auth process. This presents the Google account selection view.
182-
googleInstance.signIn()
173+
// Assigning the view controller has no effect since we don't use Google UI, but it's is required, so here we are.
174+
googleInstance.signIn(with: configuration, presenting: viewController) { user, error in
175+
self.didSignIn(for: user, error: error)
176+
}
183177
}
184178

185179
func track(_ event: WPAnalyticsStat, properties: [AnyHashable: Any] = [:]) {
@@ -188,24 +182,13 @@ private extension GoogleAuthenticator {
188182
WordPressAuthenticator.track(event, properties: trackProperties)
189183
}
190184

191-
enum LocalizedText {
192-
static let googleConnected = NSLocalizedString("Connected But…", comment: "Title shown when a user logs in with Google but no matching WordPress.com account is found")
193-
static let googleConnectedError = NSLocalizedString("The Google account \"%@\" doesn't match any account on WordPress.com", comment: "Description shown when a user logs in with Google but no matching WordPress.com account is found")
194-
static let googleUnableToConnect = NSLocalizedString("Unable To Connect", comment: "Shown when a user logs in with Google but it subsequently fails to work as login to WordPress.com")
195-
}
196-
197-
}
198-
199-
// MARK: - GIDSignInDelegate
200-
201-
extension GoogleAuthenticator: GIDSignInDelegate {
202-
203-
func sign(_ signIn: GIDSignIn?, didSignInFor user: GIDGoogleUser?, withError error: Error?) {
204-
185+
/// Handles when the sign in process is either succeeded or failed.
186+
/// This is invoked after signing in through `GIDSignIn`'s `signIn` method.
187+
func didSignIn(for user: GIDGoogleUser?, error: Error?) {
205188
// Get account information
206189
guard let user = user,
207190
let token = user.authentication.idToken,
208-
let email = user.profile.email else {
191+
let email = user.profile?.email else {
209192

210193
// The Google SignIn may have been cancelled.
211194
let failure = error?.localizedDescription ?? "Unknown error"
@@ -252,6 +235,12 @@ extension GoogleAuthenticator: GIDSignInDelegate {
252235
loginFacade.loginToWordPressDotCom(withSocialIDToken: token, service: SocialServiceName.google.rawValue)
253236
}
254237

238+
enum LocalizedText {
239+
static let googleConnected = NSLocalizedString("Connected But…", comment: "Title shown when a user logs in with Google but no matching WordPress.com account is found")
240+
static let googleConnectedError = NSLocalizedString("The Google account \"%@\" doesn't match any account on WordPress.com", comment: "Description shown when a user logs in with Google but no matching WordPress.com account is found")
241+
static let googleUnableToConnect = NSLocalizedString("Unable To Connect", comment: "Shown when a user logs in with Google but it subsequently fails to work as login to WordPress.com")
242+
}
243+
255244
}
256245

257246
// MARK: - LoginFacadeDelegate
@@ -261,7 +250,7 @@ extension GoogleAuthenticator: LoginFacadeDelegate {
261250
// Google account login was successful.
262251
func finishedLogin(withGoogleIDToken googleIDToken: String, authToken: String) {
263252
SVProgressHUD.dismiss()
264-
GIDSignIn.sharedInstance().disconnect()
253+
GIDSignIn.sharedInstance.disconnect()
265254

266255
// This stat is part of a funnel that provides critical information. Please
267256
// consult with your lead before removing this event.
@@ -284,7 +273,7 @@ extension GoogleAuthenticator: LoginFacadeDelegate {
284273
// Google account login was successful, but a WP 2FA code is required.
285274
func needsMultifactorCode(forUserID userID: Int, andNonceInfo nonceInfo: SocialLogin2FANonceInfo) {
286275
SVProgressHUD.dismiss()
287-
GIDSignIn.sharedInstance().disconnect()
276+
GIDSignIn.sharedInstance.disconnect()
288277

289278
loginFields.nonceInfo = nonceInfo
290279
loginFields.nonceUserID = userID
@@ -300,7 +289,7 @@ extension GoogleAuthenticator: LoginFacadeDelegate {
300289
// Google account login was successful, but a WP password is required.
301290
func existingUserNeedsConnection(_ email: String) {
302291
SVProgressHUD.dismiss()
303-
GIDSignIn.sharedInstance().disconnect()
292+
GIDSignIn.sharedInstance.disconnect()
304293

305294
loginFields.username = email
306295
loginFields.emailAddress = email
@@ -316,7 +305,7 @@ extension GoogleAuthenticator: LoginFacadeDelegate {
316305
// Google account login failed.
317306
func displayRemoteError(_ error: Error) {
318307
SVProgressHUD.dismiss()
319-
GIDSignIn.sharedInstance().disconnect()
308+
GIDSignIn.sharedInstance.disconnect()
320309

321310
var errorTitle = LocalizedText.googleUnableToConnect
322311
var errorDescription = error.localizedDescription

0 commit comments

Comments
 (0)