I have an iOS app that has Google Cloud SignIn using Firebase, but when opening the web to sign in, I get the following errors:
We cannot verify the authenticity of this app. Please contact the developer. Token failed.
If you are a ******* developer, see the error details.
Error 400: invalid_request
Request details: response_type=code code_challenge_method=S256 nonce=bRNSXpeJTQfPJn435Pn9C0niL5NIRzkxtb1BAIsXqu0 device_os=iOS 17.4.1 client_id=541903925667-nnvn5cctvima77nh4elc81schetiv4ok.apps.googleuser content.com emm_support=1 gpsdk=gid-7.1.0 gidenv=ios state=-KR22DP2ZWwf9bXZRWm96HGQjVt2-8KxEZ1GHYxAu3g redirect_uri=com.googleusercontent.apps.541903925667-nnvn5cctvima77nh4elc81schetiv4ok:/oauth2callback code_challenge=4ryryshF3lScPX6fJ-MSWR0AmgMsUM_OlhhFoo9P3MU include_granted_scopes=true access_type=offline scope=https://www.googleapis. com/auth/userinfo.email https://www.googleapis. com/auth/userinfo.profile openid
I checked the credentials of the GoogleService-Info.plist file that I downloaded from Firebase and both the CLIENT_ID and the REVERSED_CLIENT_ID are the same as those in my Google Cloud configuration, also, the REVERSED_CLIENT_ID is the same as the URL Type that I have in Xcode
In my Google Cloud Platform dashboard I have this config:
Inside my iOS Client for ******* (auth created by Google Service) I have this config witch are equal to my GoogleService-info file
Any idea how I can solve this error ? I remove and added again my iOS app on Firebase but the problem still continues
My code to sign in with Google are:
func sigInWithGoogle(completion: @escaping (Bool, Error?) -> Void) {
guard let rootViewController = UIApplication.shared.keyWindow?.rootViewController else { return }
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
let config = GIDConfiguration(clientID: clientID)
GIDSignIn.sharedInstance.configuration = config
GIDSignIn.sharedInstance.signIn(withPresenting: rootViewController) { signInResult, error in
if let error = error {
completion(false, error)
print("Error loggin with Google: \(error.localizedDescription)")
return
}
guard let authentication = signInResult?.user, let idToken = authentication.idToken else {
return
}
let idTokenString = idToken.tokenString
let credential = GoogleAuthProvider.credential(withIDToken: idTokenString, accessToken: signInResult?.user.idToken?.tokenString ?? "")
Auth.auth().signIn(with: credential) { authResult, error in
if let error = error {
completion(false, error)
return
}
guard let user = authResult?.user else { return }
AnalyticsManager.shared.logEvent(.loginWithGoogle)
guard let name = user.displayName else { return }
DispatchQueue.main.async {
self.defaults.set(name, forKey: Constants.UserDefaultsValues.userFirstName)
}
completion(true, nil)
}
}
}
The only way to solve it was to delete my iOS App in Firebase and register the app again, deactivate and activate the authentication again... The people at Google did not help me at all even though I paid for a support plan, if you have the same problem, don't waste your time with Google, just do those steps and you should be able to solve that error.