I have followed the instructions on https://firebase.google.com/docs/auth/ios/twitter-login to a T for Swift and I get the web popup to authorise the App I created on Twitter Dev, the callback is called and then the webview sits on an empty page of about:blank. Nothing can be done but click the Done button which then results in a Error Domain=FIRAuthErrorDomain Code=17058 “The interaction was cancelled by the user.”
Callback address is correct. I’ve used the Twitter Consumer API Keys as the keys to enter in the Firebase console.
What am I missing?
4
Answers
Ok so I resolved this question but not entirely sure how now. I believe it was because the callback wasn't being issued and thus not picked up by the app. The callback wasn't issue due to the authentication and I believe because I hadn't created the terms of service and privacy policy. So make sure you have done that in the Twitter dev page.
In the twitter dev page, the callback link is: https://yourApp.firebaseapp.com/__/auth/handler You'll find this in your firebase authentication settings when you enable twitter.
Ensure you have in info.plist LSApplicationQueriesSchemes an array of: twitter twitterauth
In your swift file:
Your button action:
Good luck! Hope this helps someone.
For everyone who still has an issue with getting callback working, I managed to fix it. Sadly, you have to edit the method in the library (not the best way, but still. Bug was reported to firebase team). The method should look like the one below (you can find it in the file named FIROAuthProvider.m, line 125. I intentionally left commented lines, so you see the problem there… Hope it helps somebody 🙂
For me there was no need in framework modifications.
As stated in a issue on GitHub: provider property should be
So I just moved its initialisation out of a function.
Before:
After:
Got stucked in about:blank page for days, tried all the above but not working, solved by add following code in AppDelegate