2

I have developed a RESTful ASP.net Web API which I am consuming from a Unity application. When testing the API it works fine in a web browser and works fine from the Unity application in Windows but in the Unity3d app on Android I get "Authorization has been denied for this request". I get this despite the fact that I am using the same credentials which worked when testing on windows or in the web browser.

When I test it in a browser (either Windows or Android) it works fine and I get the JSON output that I expect.

The API is running through HTTPS and its using IIS basic authentication. Is there something in this that can detect that I'm using Unity3D in Android and then deny the request?

The URL looks like this:

https://[username]:[password]@[api.domain.name]/Assets/[a guid]

The controller looks like this:

public class AssetsController : ApiController
{
    [Authorize]
    public IHttpActionResult Get(Guid id)
    {
        AssetLogic assetLogic = new AssetLogic();
        List<Asset> Assets = assetLogic.GetCompanyAssets(id).ToList();
        return Ok(Assets);
    }
}

I have this in my global.asax:

protected void Application_Start(object sender, EventArgs e)
{
        GlobalConfiguration.Configuration.Routes.MapHttpRoute("Default", 
            "{controller}/{id}", 
            new { id = RouteParameter.Optional });

        GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
}

Any help is much appreciated!

Salbrox
  • 143
  • 1
  • 15

0 Answers0