Skip to content

Commit 8650116

Browse files
Update GoogleSignIn pod to 7.1.0
1 parent 43125e4 commit 8650116

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

CodetrixStudioCapacitorGoogleAuth.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
1111
s.ios.deployment_target = '12.0'
1212
s.dependency 'Capacitor'
13-
s.dependency 'GoogleSignIn', '~> 6.2.4'
13+
s.dependency 'GoogleSignIn', '~> 7.1.0'
1414
s.static_framework = true
1515
end

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,11 @@ or see more [CapacitorGoogleAuth-Vue3-example](https://github.com/reslear/Capaci
147147

148148
1. Create in Google cloud console credential **Client ID for iOS** and get **Client ID** and **iOS URL scheme**
149149

150-
2. Add **identifier** `REVERSED_CLIENT_ID` as **URL schemes** to `Info.plist` from **iOS URL scheme**<br>
151-
(Xcode: App - Targets/App - Info - URL Types, click plus icon)
150+
2. Add **identifier** `GIDClientID` to `Info.plist`<br>
151+
`<key>GIDClientID</key><string>VALUE</string>`
152152

153-
3. Set **Client ID** one of the ways (by order of importance in the plugin):
154-
1. Set `clientId` in initialize method
155-
2. Set `iosClientId` in `capacitor.config.json`
156-
3. Set `clientId` in `capacitor.config.json`
157-
4. Set `CLIENT_ID` in `GoogleService-Info.plist`
153+
3. Add **identifier** `REVERSED_CLIENT_ID` as **URL schemes** to `Info.plist` from **iOS URL scheme**<br>
154+
(Xcode: App - Targets/App - Info - URL Types, click plus icon)
158155

159156
### Android
160157

ios/Plugin/Plugin.swift

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,26 @@ public class GoogleAuth: CAPPlugin {
7777
self.signInCall?.reject(error.localizedDescription);
7878
return;
7979
}
80-
self.resolveSignInCallWith(user: user!)
80+
self.resolveSignInCallWith(user: user!, serverAuthCode: nil)
8181
}
8282
} else {
8383
let presentingVc = self.bridge!.viewController!;
8484

85-
self.googleSignIn.signIn(with: self.googleSignInConfiguration, presenting: presentingVc, hint: nil, additionalScopes: self.additionalScopes) { user, error in
85+
self.googleSignIn.signIn(
86+
withPresenting: presentingVc,
87+
hint: nil,
88+
additionalScopes: self.additionalScopes
89+
) { signInResult, error in
8690
if let error = error {
8791
self.signInCall?.reject(error.localizedDescription, "\(error._code)");
8892
return;
8993
}
90-
self.resolveSignInCallWith(user: user!);
91-
};
94+
95+
let user = signInResult?.user;
96+
let serverAuthCode = signInResult?.serverAuthCode;
97+
98+
self.resolveSignInCallWith(user: user!, serverAuthCode: serverAuthCode);
99+
}
92100
}
93101
}
94102
}
@@ -100,18 +108,13 @@ public class GoogleAuth: CAPPlugin {
100108
call.reject("User not logged in.");
101109
return
102110
}
103-
self.googleSignIn.currentUser!.authentication.do { (authentication, error) in
104-
guard let authentication = authentication else {
105-
call.reject(error?.localizedDescription ?? "Something went wrong.");
106-
return;
107-
}
108-
let authenticationData: [String: Any] = [
109-
"accessToken": authentication.accessToken,
110-
"idToken": authentication.idToken ?? NSNull(),
111-
"refreshToken": authentication.refreshToken
112-
]
113-
call.resolve(authenticationData);
114-
}
111+
112+
let authenticationData: [String: Any] = [
113+
"accessToken": self.googleSignIn.currentUser!.accessToken,
114+
"idToken": self.googleSignIn.currentUser!.idToken ?? NSNull(),
115+
"refreshToken": self.googleSignIn.currentUser!.refreshToken
116+
]
117+
call.resolve(authenticationData);
115118
}
116119
}
117120

@@ -161,14 +164,14 @@ public class GoogleAuth: CAPPlugin {
161164
return nil;
162165
}
163166

164-
func resolveSignInCallWith(user: GIDGoogleUser) {
167+
func resolveSignInCallWith(user: GIDGoogleUser, serverAuthCode: String?) {
165168
var userData: [String: Any] = [
166169
"authentication": [
167-
"accessToken": user.authentication.accessToken,
168-
"idToken": user.authentication.idToken,
169-
"refreshToken": user.authentication.refreshToken
170+
"accessToken": user.accessToken.tokenString,
171+
"idToken": user.idToken?.tokenString,
172+
"refreshToken": user.refreshToken.tokenString
170173
],
171-
"serverAuthCode": user.serverAuthCode ?? NSNull(),
174+
"serverAuthCode": serverAuthCode ?? NSNull(),
172175
"email": user.profile?.email ?? NSNull(),
173176
"familyName": user.profile?.familyName ?? NSNull(),
174177
"givenName": user.profile?.givenName ?? NSNull(),

0 commit comments

Comments
 (0)