Announcement Announcement Module
No announcement yet.
Twitter single-user OAuth Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Twitter single-user OAuth


    I'm trying to adapt my code to the twitter API changes. As I only use the search endpoint I want to use the client authorization. In TwitterTemplate doc I see that I should check out the new endpoint OAuth2Operations.authenticateClient().

    Maybe I missed something but from a TwitterConnectionFactory object I cannot get an OAuth2Operations instance. It would be perfect if I could do something like this for connecting:

     TwitterConnectionFactory connectionFactory = new TwitterConnectionFactory(consumerKey, consumerSecret);
     OAuth2Operations oauthOperations = connectionFactory.getOAuth2Operations();
     TwitterTemplate twitter = new TwitterTemplate(oauthOperations.authenticateClient().getAccessToken());

    So, I think that in the latest version there is not a service provider class that extends AbstractOAuth2ServiceProvider for twitter no? So I would have to implement it no?


  • #2
    That's right. Client authorization doesn't involve connections (which are the link between an API and a client on behalf of a user). Therefore it isn't available through the connection API.

    You can simply create an instance of OAuth2Template, however and use that. I might consider exposing the OAuth2Operations in a connection factory, you don't have to duplicate client credentials. But at the moment, you need to create your own instance of OAuth2Operations.