check appid

This commit is contained in:
Tommy Parnell
2016-12-02 16:35:11 -05:00
parent 15dc1f6745
commit d449a567bb
2 changed files with 14 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ using AlexaSkillsKit.Authentication;
using AlexaSkillsKit.Json; using AlexaSkillsKit.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using AlexaSkillsKit.UI; using AlexaSkillsKit.UI;
using System.Diagnostics;
namespace alexa.dev.excuses namespace alexa.dev.excuses
{ {
@@ -24,6 +25,16 @@ namespace alexa.dev.excuses
return CompileResponse(); return CompileResponse();
} }
public override bool OnRequestValidation(SpeechletRequestValidationResult result, DateTime referenceTimeUtc, SpeechletRequestEnvelope requestEnvelope)
{
if(!string.IsNullOrWhiteSpace(requestEnvelope?.Session?.Application?.Id) && !requestEnvelope.Session.Application.Id.Equals("amzn1.ask.skill.2327a089-3c06-47f7-accb-4b627136b652"))
{
WebApiApplication.telemetry.TrackEvent("Request envelope does not contain the appid");
return false;
}
return base.OnRequestValidation(result, referenceTimeUtc, requestEnvelope);
}
public override void OnSessionEnded(SessionEndedRequest sessionEndedRequest, Session session) public override void OnSessionEnded(SessionEndedRequest sessionEndedRequest, Session session)
{ {
} }

View File

@@ -1,4 +1,5 @@
using System; using Microsoft.ApplicationInsights;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
@@ -9,6 +10,7 @@ namespace alexa.dev.excuses
{ {
public class WebApiApplication : System.Web.HttpApplication public class WebApiApplication : System.Web.HttpApplication
{ {
public static TelemetryClient telemetry = new TelemetryClient() { InstrumentationKey = "69bdd5ac-c992-4daa-89c9-7af1dbd09249" };
protected void Application_Start() protected void Application_Start()
{ {
GlobalConfiguration.Configure(WebApiConfig.Register); GlobalConfiguration.Configure(WebApiConfig.Register);