I'm calling a custom Azure Function from Unity via UnityWebRequest that validates the player with Meta then logs in to PlayFab LoginWithServerCustomId API.
[FunctionName("LogInViaOculus")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
string reqBody = await req.ReadAsStringAsync();
LoginArgs args = JsonConvert.DeserializeObject<LoginArgs>(reqBody);
var client = new HttpClient();
// Meta validation code redacted
// bool createNew and string customId from form
client.DefaultRequestHeaders.Add("X-SecretKey", "MYACTUALAPPSECRETCODEGOESHERE");
var loginReqCont = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("CreateAccount", args.createNew.ToString()),
new KeyValuePair<string, string>("ServerCustomId", args.customId),
});
string loginUri = $"https://APPID.playfabapi.com/Server/LoginWithServerCustomId";
HttpResponseMessage loginResponse = await client.PostAsync(
loginUri, loginReqCont);
if (!loginResponse.IsSuccessStatusCode)
{
log.LogError($"PlayFab Login Error {loginResponse.StatusCode}: {loginResponse.ReasonPhrase}");
return new BadRequestObjectResult($"PlayFab Login Error {loginResponse.StatusCode}: {loginResponse.ReasonPhrase}");
}
string loginResult = null;
using (var reader = new StreamReader(await loginResponse.Content.ReadAsStreamAsync()))
{
loginResult = await reader.ReadToEndAsync();
}
return new OkObjectResult(loginResult);
}
But this returns 400 Bad Request and no other data. Did I miss an authentication? Is there a wait to get more data out of this error?