TwitterKit 3.0.4 Opening link in Safari browser, as the host is not whitelisted

ios
oauth
bug
safari

#1

Hi,
I’ve recently update TwitterKit to 3.0.4. I’ve done the installation instructions from the site and I’ve put the URLShema at the first place in plist file as suggested in here.
But after the user login in the SafariViewController I’m getting message

Opening link in Safari browser, as the host is not whitelisted: twitterkit-<myConsumerKey >://callback?app=<myConsumerKey>&oauth_token=<token>&oauth_verifier=<oauth>

Am I missing something?


#2

I’m seeing the same issue


#3

I’m also seeing this, but it doesn’t appear to cause any problems?


#4

In my case the control never returns to the application, the safari view control just sits there displaying “redirecting you back to the application”


#5

Hey guys, have you tried updating to TwitterKit 3.1.0 to see if the issue persists?


#6

Literally in the process of trying this now, will post with results momentarily.

Done. result is the same… The login attempt just hangs up in Safari and never redirects back to the app, with the message Opening link in Safari browser, as the host is not whitelisted: twitterkit-1234://callback?app=1234&oauth_token=jUj20gAAAAAA0tk9AAABXht3qJc&oauth_verifier=5XeKcrimVQbrjmJvsb5GaG84wsabzC6z

note: I replaced the app id with 1234


#7

Thanks for checking that! Could you provide me with more information about how your app is set up (plist file with the keys obfuscated, how you are implementing the twitterkit stuff in app delegate and how you are using twitterkit in your app)?

Thanks!


#8

Sure, in applicationDidFinishLaunchingWithOptions we’ve got

Twitter.sharedInstance().start(withConsumerKey: "foo", consumerSecret: "bar"),

then in info.plist,

<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>twitterkit-foo</string>
			</array>
		</dict>
	</array>
       ...

And then this for Fabric, not sure if the Kit config here is redundant or not now, we’ve migrated a few times.

<key>Fabric</key>
	<dict>
		<key>APIKey</key>
		<string>baz</string>
		<key>Kits</key>
		<array>
			<dict>
				<key>KitInfo</key>
				<dict>
					<key>consumerKey</key>
					<string>foo</string>
					<key>consumerSecret</key>
					<string>bar</string>
				</dict>
				<key>KitName</key>
				<string>Twitter</string>
			</dict>
		</array>
	</dict>

and lastly

<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>twitter</string>
		<string>twitterauth</string>
		<string>itms-apps</string>
		<string>fbauth2</string>
		<string>fbapi</string>
		<string>fb-messenger-api</string>
		<string>fbshareextension</string>
	</array>

and logging in with

Twitter.sharedInstance().logIn(completion: { session, error in 
    ....
})

#9

Are you implementing the method for opening URLs in your AppDelegate?

// Swift
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
   return Twitter.sharedInstance().application(app, open: url, options: options)
}

#10

Just took a look and this method was not implemented - implementing it seems to have resolved the issue. Assuming this is necessary now for the v3+ version of twitterkit?


#11

Yes I think this is part of v3+ release, it’s referenced here in the documentation.


#12

@_paulbuchanan @The_Dudi can you guys also confirm if this fixes your issue?


#13

The web view login works just fine for me. I have the app delegate URL handling method implemented. I do see the message on the console about not being white listed, but everything seems to work fine with login. That message must not be meaningful.


#14

Guys, i have did all the implementation right, it didn’t work with 3.4 it kept on going to twitter app, then go to web view and then display this error.

I started going back version by version until 3.0.0 worked out, so do the following:

pod 'TwitterKit', '~> 3.0.0.0' , :inhibit_warnings => true
pod 'TwitterCore', '~> 3.0.0.0', :inhibit_warnings => true

This should work perfectly, and call Twitter.sharedInstance().application(app, open: url, options: options), I’ve tested it with latest twitter app it worked to login, if app is not installed then it will show the web view and thats all .

Finally.