I've been stuck in authentication problems for a long time now and I've tried everything that was possible to do but I can't find a solution for this problem.
I am using Azure Mobile Services as a backend to my app and everything works perfectly except for the authentication part. I am pretty sure I followed every single step of the documentation and revised it again and again.
The error happens after using LoginAsync(): "Cannot GET /.auth/login/twitter?................etc"
Here is my AppDelegate Code for Xamarin.iOS:
[Register("AppDelegate")]
public partial class AppDelegate : FormsApplicationDelegate, IAuthenticate
{
private MobileServiceUser user { get; set; }
public async Task<bool> Authenticate()
{
var res = false;
if(user == null){
//var json = new JObject();
//json.Add("access_token","my token");
Dictionary<string,string> dict = new Dictionary<string,string>();
dict.Add("access_token","my token");
try
{
user = await MyManager.DefaultManager.CurrentClient.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController.PresentedViewController,
MobileServiceAuthenticationProvider.Twitter,
"my scheme");
if (user == null)
{
res = false;
}
else
{
res = true;
}
}catch(Exception e){
System.Diagnostics.Debug.WriteLine("Login Status: " + e.Message);
}
}
System.Diagnostics.Debug.WriteLine("Login Status: "+res);
return res;
}
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
return MyManager.DefaultManager.CurrentClient.ResumeWithURL(url);
}
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
//Initializing authenticator
App.Init(this);
LoadApplication(new App());
UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);
return base.FinishedLaunching(app, options);
}
Note that when I change the "Action to take when request is not authenticated" to other than "nothing," it redirects to Facebook authentication (Which surprisingly works this way!!) automatically even if I chose Twitter, but I don't get the result in the app.
Thank you very much