in SfB Trusted Application/Controllers/GetAnonTokenJobController.cs [24:66]
public async Task<HttpResponseMessage> PostAsync(GetAnonTokenInput input)
{
if (string.IsNullOrEmpty(input.ApplicationSessionId))
{
return CreateHttpResponse(HttpStatusCode.BadRequest, "{\"Error\":\"No or invalid callback context specified!\"}");
}
if (string.IsNullOrEmpty(input.AllowedOrigins))
{
return CreateHttpResponse(HttpStatusCode.BadRequest, "{\"Error\":\"Invalid AllowedOrigins\"}");
}
string jobId = Guid.NewGuid().ToString("N");
try
{
PlatformServiceSampleJobConfiguration jobConfig = new PlatformServiceSampleJobConfiguration
{
JobType = JobType.GetAnonToken,
AnonTokenJobInput = input
};
var job = PlatformServiceClientJobHelper.GetJob(jobId, WebApiApplication.InstanceId, WebApiApplication.AzureApplication, jobConfig) as GetAnonTokenJob;
if (job == null)
{
return CreateHttpResponse(HttpStatusCode.BadRequest, "{\"Error\":\"Invalid job input or job type\"}");
}
AnonymousToken token = await job.ExecuteWithResultAsync<AnonymousToken>().ConfigureAwait(false);
if (token == null)
{
return CreateHttpResponse(HttpStatusCode.InternalServerError, "{\"Error\":\"Job did not return a token\"}");
}
return Request.CreateResponse(HttpStatusCode.OK, token);
}
catch (Exception ex)
{
telemetry.TrackException(ex);
Logger.Instance.Error(ex, "Exception while scheduling job.");
return CreateHttpResponse(HttpStatusCode.InternalServerError, "{\"Error\":\"An unexecpted error occured while starting the job.\"}");
}
}