Reputation: 489
I use Firebase in my iOS app for analytics, cloud messaging... and everything is working properly. Now I need to link the app to a different Firebase project to do Firebase authentication. This project is the Firebase project created on Google Cloud when setting up Google Cloud Identity platform. I followed the Firebase guide that explains how to configure multiple projects.
In AppDelegate
I've the following code to configure the 2 projects:
//Configure default project
FirebaseApp.configure()
//Configure project for authentication
let plist = Bundle.main.path(forResource: "GoogleService-Info-auth", ofType: "plist")
let options = FirebaseOptions(contentsOfFile: plist!)
FirebaseApp.configure(name: "auth", options: options!)
Default GoogleService-Info.plist
and GoogleService-Info-auth.plist
are present in the XCode project. Then in a view controller, I first load the second app:
let app = FirebaseApp.app(name: "auth")
and then create the auth object:
let auth = Auth.auth(app: app)
If look at auth
in the debugger, I see that auth.app
is correctly configured and link to the second project. But, when I do:
provider = OAuthProvider(providerID: "providerID")
provider.getCredentialWith(nil) { credential, error in
if error != nil {
// Handle error.
}
if credential != nil {
auth.signIn(with: credential) { authResult, error in
if error != nil {
// Handle error.
}
// User is signed in.
}
}
}
I get the error that I haven't registered the custom URL scheme in the Info.plist
. But this scheme corresponds to the default project and not the one I asked to use. I assumed that maybe it is a wrong check of the library and also defined the custom url scheme for the default project but then I get the following error:
[auth/operation-not-allowed] - Use of this method requires GCIP. For more information, see the [Firebase API reference](https://firebase.google.com/docs/reference/js/firebase.auth.OAuthProvider)
It tells me that the OAuth provider is not configured. I did not configured anything on the default project so this is correct but I want that the sign-in takes the second one and I think the library is not doing it.
Firebase authentication works correctly if I only configure the second project in the app so I assume that there is an issue with setting-up a different app/project for Firebase authentication only.
What do you think?
Upvotes: 1
Views: 284
Reputation: 489
provider = OAuthProvider(providerID: "providerID", auth: auth)
fixes the issue. The OAuthProvider
also need to be configured with the second project.
Upvotes: 1