Search code examples
javaoauthplayframeworktwitter-oauthplayframework-2.4

Twitter sign-in inPlay Framework


I am trying to create an application that interacts with users'twitter accounts. (Tweets based on triggers). This is my first time interacting with OAuth, so please bare with my ignorance :).

I think I need two things :

  • Have users authorize the app so that I can perform operations on their behalf. As far as I understand the authorization is a one time only operation.
  • Allow users to sign in the application using Twitter.

I have followed the excellent JAvaOAuth tutorial and I already am successfully posting tweets. The problem is that the tokens in the example are stored in a cookie, meaning that closing the browser deletes everything. Every time I access the application again I am redirected to the Authorization page.

To make things more permanent, I understand I have to save those tokens in the database. Now this is fine, but how do I handle Sign in ? Is it a completely different workflow? The implementing sign-in page of the Twitter docs is so close from what is performed in the JavaOAuth tutorial that I am a bit lost.

I guess I could implement sign-in myself, but since I only interact with Twitter I think using Twitter sign-in would be way neater.

Last but not least, I have looked at SecureSocial but sadly the project looks on a standstill and is still only 2.3 compliant.

Any direction on how to implement sign-in in a correct way would be most appreciated.

Thanks!


Solution

  • Ok, so this documentation page helped me as expected.

    To get this answer working fine, you will have to already have implemented the sample documented here.

    Then, as mentioned in the documentation, simply replace this url :

    https://dev.twitter.com/oauth/reference/get/oauth/authorize

    with this :

    https://dev.twitter.com/oauth/reference/get/oauth/authenticate

    in your sample.

    Annnnnd, this should work fine. Easier than expected :).