I'm building an app (with xamarin.forms pcl ), where I have a facebook login using the Azure Mobile Client SDK . It is possible to perform the authentication, however, soon after the authentication, I try to make a listing in the api url: link and I have the 401 Unauthorized return.
Since the login with the social network was successful. The evidence follows:
CodewhereIhavetheproblem:
publicasyncTask<List<Tipo>>GetTipoAsync(){varhttpClient=newHttpClient();httpClient.DefaultRequestHeaders.Accept.Add(newMediaTypeWithQualityHeaderValue("application/json"));
var response = await httpClient.GetAsync($"{BaseUrl}Tipo").ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
{
return JsonConvert.DeserializeObject<List<Tipo>>(
await new StreamReader(responseStream).ReadToEndAsync().ConfigureAwait(false));
}
}
return null;
}
Note: Before putting the authentication with facebook, the access to api and the get of the data for listing worked correctly. The problem is that you are giving this access without authorization in the url, even after being logged in. Note 2: It is possible to test the api in the browser, with facebook authentication, and it works correctly.