OAuth and logging on to Twitter

We'll take a detour into LoginController in just a moment, but first, let's make sure we understand what's going on here. To log on to Twitter on behalf of a user, we need to generate an OAuth request token from which we get an authorization URL. The details of which are hidden nicely behind the Twitter4J API, but it is, basically, the OAuth authorization URL listed on the Application Management page with a request token passed as a query string. As we'll see, this URL is opened in a WebView, which prompts the user to authenticate against Twitter, and then authorize the application (or decline to):

If the user ...

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.