I have implemented Google sign in via Firebase and followed proper documentation: https://firebase.google.com/docs/auth/ios/firebaseui
I am using,
- FirebaseUI/Auth (8.5.1):
- Firebase/Auth (~> 6.0)
- GoogleUtilities/UserDefaults
- FirebaseUI/Google (8.5.1):
- FirebaseUI/Auth
- GoogleSignIn (~> 5.0)
COCOAPODS: 1.9.3
XCode - 12
So, my Appdelegate.swift
would contain following code in didFinishLaunchingWithOptions
...
FirebaseApp.configure()
And presenting SignIn UI when user presses a special button on Login view controller using below code,
if let authController = authUI?.authViewController() {
self.authController = authController
self.present(authController, animated: true, completion: nil)
}
LoginViewController.swift
would have following code into viewDidload()
authUI?.delegate = self
let providers: [FUIAuthProvider] = [
FUIGoogleAuth()
]
authUI?.providers = providers
where authUI
is declared as property for LoginViewController
=> let authUI = FUIAuth.defaultAuthUI()
I have only added Google SignIn for now so only one provider added here.
Now when my SignIn Auth UI is presented, Google SignIn button is shown and I am able to log into my Google account but when didSignInWith authDataResult
is executed from FUIAuthDelegate
, I get to know I am receiving an error post successful Google Account Login.
Error Domain=FUIAuthErrorDomain Code=2 "(null)" UserInfo={FUIAuthErrorUserInfoProviderIDKey=google.com, NSUnderlyingError=0x600000a08720 {Error Domain=org.openid.appauth.general Code=-15 "Audience mismatch" UserInfo={NSLocalizedDescription=Audience mismatch}}}
Is there anything I am missing?
I have already setup URL schema into info.plist
and not getting any clue on how this kind of error is being generated.
Further as an update to @frank-van-puffelen,
I have confirmed proper info.plist is added or not.
My Info.Plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>847792004435-gdisqis038je5q8rr1on4ti7df09nvht.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.847792004435-gdisqis038je5q8rr1on4ti7df09nvht</string>
<key>API_KEY</key>
<string>AIzaSyDRrYM2h1wOEdKHZtOM-M904oBwrXnaO3E</string>
<key>GCM_SENDER_ID</key>
<string>847792004435</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.Speare.StashAlpha</string>
<key>PROJECT_ID</key>
<string>stash-demo-11379</string>
<key>STORAGE_BUCKET</key>
<string>stash-demo-11379.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:847792004435:ios:867e5fb8113b83b48f55a6</string>
<key>DATABASE_URL</key>
<string>https://stash-demo-11379.firebaseio.com</string>
</dict>
</plist>
Screenshot of project which is targeted for login,
We can clearly check here Project ID matches in info.plist
as well as on Sign In screen.
Now in Firebase console, if we check, project ID matches and below is info.plist
download button from where I can take latest info.plist.
Let me know if there is anything we can confirm info.plist does not match with target project.