Search code examples
c#authenticationxamarinxamarin.formslinq-to-twitter

Xamarin.Forms LinqToTwitter Authorization fail


I have tested the following code for authorization in normal C# console application and everything works well:

          var  Authorizor = new SingleUserAuthorizer()
        {
            CredentialStore = new SingleUserInMemoryCredentialStore
            {
                ConsumerKey = "conskey",
                ConsumerSecret = "conssec",
                AccessToken = "accesstok",
                AccessTokenSecret = "accesssec"
            }
        };

This works well and loads everything I need and no problems.

When I tried the same code in Xamarin.Forms application, it keeps throwing this error:

{"Invalid character '\u001f' in input string"}

I have been looking this up for hours and I cannot seem to make it work. I found some suggestions to make it load from appSettings but Xamarin.Forms does not have any of that. Any ideas?


Solution

  • I have just figured out the problem and the reason.

    LinqToTwitter did not release generic support for UWP which means that when UWP is part of Xamarin.Forms, LinqToTwitter cannot be used as is.

    LinqToTwitter have released a version specially targeting UWP and ONLY works on UWP. It uses different type of Authorizer called UniversalAuthorizer (does not exist on Xamarin.Forms and cannot be used by it, unfortunately).

    For the moment, if you are developing cross-platform using Xamarin.Forms and LinqToTwitter, then you should be creating a different library for UWP and specialize it for that purpose.