Serviço de Aplicativo do Azure - Autenticação personalizada - Verbo HTTP não permitido
Segui este tutorial para ativar a autenticação no meu aplicativo Xamarin.Forms:https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter2/custom/
Um teste com o Postman (conforme descrito no tutorial) foi bem-sucedido. O token retornou.
Quando eu chamo isso do meu código C # ...
LoginAsync("custom", Newtonsoft.Json.Linq.JObject.FromObject(auth));
Eu recebi um erro como:
Method not allowed. HTTP Verb not allowed
Descobri que o SDK do Azure envia uma solicitação POST e GET ao chamar LoginAsync. Então eu mudei isso ...
[HttpPost, Route(".auth/login/custom")]
public IHttpActionResult Post([FromBody]CPM.Arda.Mobile.Freelancer.Backend.DataObjects.Recruitment.Custom.PromoterAuthRequest promoterAuth)
para isso...
[HttpPost, HttpGet, Route(".auth/login/custom")]
public IHttpActionResult Post([FromBody]CPM.Arda.Mobile.Freelancer.Backend.DataObjects.Recruitment.Custom.PromoterAuthRequest promoterAuth)
O erro HTTP Verb se foi, mas ocorre o seguinte erro:
Operation=ReflectedHttpActionDescriptor.ExecuteAsync, Exception=System.NullReferenceException: Object reference not set to an instance of an object.
at CPM.Arda.Mobile.Freelancer.Backend.Controllers.Custom.CustomAuthController.Post(PromoterAuthRequest promoterAuth)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.MoveNext()
2017-07-11T10:39:50 PID[9680] Error Operation=ApiControllerActionInvoker.InvokeActionAsync, Exception=System.NullReferenceException: Object reference not set to an instance of an object.
at CPM.Arda.Mobile.Freelancer.Backend.Controllers.Custom.CustomAuthController.Post(PromoterAuthRequest promoterAuth)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
Estou realmente confuso. Nenhum tutorial disponível para este tópico parece funcionar imediatamente.