Skip to content

The window stays open after authorizing "allow"

jpurcell edited this page Aug 3, 2011 · 1 revision

First check to see that you can log in to Twitter's site. If Twitter's site isn't working, then the app won't work.

If that isn't the issue, then it's almost 100% certain that the window isn't stopping at the specified callback URL. Just after Twitter redirects to the callback, the page is getting redirected.

How the verification works is after the request tokens are retrieved, a window (webView) will pop up requesting the user to "Allow" your app to access the user's Twitter account. The window will not close until it has found "oauth_verifier" in the URL. If the page is forwarded, the URL change listener won't pick up that the page has been redirected and the data Twitter has just returned, the oauth_verifier, will be dropped.

For example, my callback url is http://site.com as specified by my Twitter App's config on Twitter's site. Because http://site.com has a PHP header() redirect command, I override the callback when I initialize the BirdHouse class (as shown at top). So, my callback is now http://site.com/twitter_callback.php. The webView window, after clicking "allow", will forward on to that callback url and Twitter will send the response data in the URL. So the webView will forward to http://site.com/twitter_callback.php?oauth_verifier=blahblah&oauth_token=blahblahbbblah. If we were still using just http://site.com as our callback, then, obviously, the URL data Twitter just sent is dropped because our site's index.php page has a header() command. Unfortunately, the "listener" in BirdHouse doesn't pick up that it ever went to http://site.com/twitter_callback.php?oauth_verifier=blahblah&oauth_token=blahblahbbblah, only the final page. This is really annoying and can't be fixed because the webView 'load' event is too slow.

If you find a value returned for the "oauth_verifier" in your console output, then you have a different issue and you should post an issue ticket.