How to use Xamarin.Auth with Twitter?

MattHarringtonMattHarrington USMember, University

I'm looking for an example of how to use Xamarin.Auth with Twitter. The docs which come with the component have a sample for Facebook, but I don't see one for Twitter.

I've found a few Xamarin.Auth and Twitter examples online, but they're a couple of years old and don't behave as expected. For example: http://www.codeproject.com/Tips/852742/Simple-Twitter-client-using-Xamarin-Forms-Xamarin. It's not clear how to prevent the callback URL from being displayed. It also seems that the event passed to the Completed event handler says the user is not authenticated, even though correct credentials are entered.

Any pointers would be appreciated.

Answers

  • rene_ruppertrene_ruppert DEXamarin Team, University, XamUProfessors Xamurai

    There should not be a difference really with Twitter being one of the available providers.
    We have documentation here: https://developer.xamarin.com/guides/xamarin-forms/web-services/authentication/oauth/

    There's also a new version of Xam.Auth which can be used from a PCL. Tick Nuget's prerelease checkbox to see it. Maybe that helps.

  • MattHarringtonMattHarrington USMember, University

    Thanks for the heads-up about the Xam.Auth alpha. I tried version 1.3.0-alpha-03, but still had no luck.

    The code in this article worked in the past, but does not appear to currently work:

    https://visualstudiomagazine.com/articles/2014/04/01/using-oauth-twitter-and-async-to-display-data.aspx

    I contacted the author, and he confirmed the problem.

  • MattHarringtonMattHarrington USMember, University

    In case my March 8 response wasn't clear, the Xamarin.Auth plugin does not appear to work with Twitter. I've confirmed this with two other developers.

  • BhavinUdaniBhavinUdani USMember
    edited April 3

    I have successfully used Twitter with Xamarin.Auth, the main issue I found was callback url giving 403 Authorization forbidden error. I solved it with comment I came across, I can't post a link here, so I am copy pasting comment that has helped me. Following is the comment that has helped me

    OK, after revisiting this on multiple occasions I did one last desperate google search and found the answer. The issue is the callback url is changing from twitter.com to m.twitter.com (or something like that) which causes Xamarin.Auth to think that it never made it to the callback url.

    I solved this by setting the callback url to my own url that I knew would not redirect.

    I will leave the issue open for you to close when you get a chance.

    Thanks again for the sample and for trying to help me with it.

    Carl Barton

Sign In or Register to comment.