MartinGian
MartinGian

Reputation: 395

Invoking InvokeApiAsync Mobile App Services

I'm working on a Xamarin.Forms project, and I'm having a really weird issue. This code is actually executing in Xamarin.Droid project.

When I try to do this

var user = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Facebook);

if (user != null)
{
    try
    {
        // executes this line
        var userInfo = await client.InvokeApiAsync("/.auth/me");
        // down here nothing is executed and userInfo is never set with the data
    }
    catch (Exception e)
    {
        // never enter to this block
    }
}

The userInfo variable is never set with the data, and no exceptions and nothing rare in the Output.

I already tried client.InvokeApiAsync("/.auth/me", HttpMethod.Get, null) but no works neither.

I know this is quite short information but I haven't anything else, because no exception is raised.

Thanks.

Upvotes: 0

Views: 93

Answers (2)

MartinGian
MartinGian

Reputation: 395

I finally figured out what was the problem. The event handler that initiates the logic of authentication, returned void instead of Task, so the async call never continues after await call.

This is something for remind.

Thanks @Amor - MSFT for your answer.

Upvotes: 0

Amor
Amor

Reputation: 8491

I followed this article to add authentication to my Xamarin Forms app. It worked fine on my side. There are some things you need to check on your project.

  1. Have you published your Azure Mobile Service to Azure and turn on the Authentication & configured Facebook app-id and secret.

enter image description here

  1. Have you connected your mobile service from your mobile client.

enter image description here

Upvotes: 1

Related Questions