- Home /
Azure Mobile Services Authentication with Facebook always gives Unauthorized error
I've been trying to create unity application and connect it with mobile services. I'm trying to do FB authentication and here's what I've done on my checklist :
Registered my FB App Id and App secret properly on mobile services.
For testing I use FB tools to generate access token for now.
Here's my code to login to FB using bitrave : // token is hardcoded with access token from FB tools for test AuthenticationToken authToken = CreateToken(provider, token); _LoginAsyncCallback = callback;
var path = "/login/" + provider.ToString().ToLower();
var baseClient = new RestClient(_baseEndPoint);
var request = new RestRequest(path, Method.POST);
var json = SerializeObject(authToken);
request.RequestFormat = DataFormat.Json;
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", json, ParameterType.RequestBody);
var handle = baseClient.ExecuteAsync<MobileServiceUser>(request, LoginAsyncHandler);
provider is "facebook" and my post is {"access_token":"XXXXXXXX"} so this should be correct right?
I always get this error : Rest Response:{"code":401,"error":"Error: The Facebook Graph API access token authorization request failed with HTTP status code 400"}
I've tried many FB app settings and generate new access tokens from fb tools, etc but nothing seems to work. I'm at my wits end on this
Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220612044545im_/https://answers.unity.com/themes/thub/images/avi.jpg)