public HttpResponseMessage Canvas(String tenantId, String flowId, String playerUrl)
        {
            String              redirectUrl   = null;
            String              signedRequest = null;
            CanvasRequest       canvasRequest = null;
            HttpResponseMessage response      = null;

            try
            {
                // Get the signed request from the form post
                signedRequest = System.Web.HttpContext.Current.Request.Form["signed_request"];

                // Grab the canvas request object from the post
                // The secret needs to be stored somewhere - actually, it doesn't - we don't need the secret at all
                canvasRequest = SalesforceCanvasUtils.VerifyAndDecode(null, signedRequest, "6156156167154975556");

                if (flowId == null ||
                    flowId.Trim().Length == 0)
                {
                    throw new ArgumentNullException("BadRequest", "A flow identifier is required.  Please pass in a parameter for \"flow-id\".");
                }

                if (tenantId == null ||
                    tenantId.Trim().Length == 0)
                {
                    throw new ArgumentNullException("BadRequest", "A tenant identifier is required.  Please pass in a parameter for \"tenant-id\".");
                }

                if (playerUrl == null ||
                    playerUrl.Trim().Length == 0)
                {
                    throw new ArgumentNullException("BadRequest", "A player is required.  Please pass in a parameter for \"player-url\".");
                }

                // Construct the redirect url so the player knows what to do
                redirectUrl  = "";
                redirectUrl += SettingUtils.GetStringSetting(SETTING_SERVER_BASE_PATH) + "/" + tenantId + "/play/" + playerUrl;
                redirectUrl += "?session-token=" + canvasRequest.client.oauthToken;
                redirectUrl += "&session-url=" + HttpUtility.HtmlEncode(canvasRequest.client.instanceUrl + canvasRequest.context.links.partnerUrl);

                // Create the run url stuff using utils
                redirectUrl = RunUtils.CompleteRunUrl(redirectUrl, Guid.Parse(flowId));

                // Tell the caller to redirect back to the desired location
                response = Request.CreateResponse(HttpStatusCode.RedirectMethod, redirectUrl);
                response.Headers.Add("Location", redirectUrl);
            }
            catch (Exception exception)
            {
                throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
            }

            return(response);
        }
        public HttpResponseMessage SessionSignIn(String tenantId, String flowId, String playerUrl, String sessionId, String sessionUrl)
        {
            String redirectUrl           = null;
            HttpResponseMessage response = null;

            try
            {
                if (flowId == null ||
                    flowId.Trim().Length == 0)
                {
                    throw new ArgumentNullException("BadRequest", "A flow identifier is required.  Please pass in a parameter for \"flow-id\".");
                }

                if (tenantId == null ||
                    tenantId.Trim().Length == 0)
                {
                    throw new ArgumentNullException("BadRequest", "A tenant identifier is required.  Please pass in a parameter for \"tenant-id\".");
                }

                if (playerUrl == null ||
                    playerUrl.Trim().Length == 0)
                {
                    throw new ArgumentNullException("BadRequest", "A player is required.  Please pass in a parameter for \"player-url\".");
                }

                // Construct the redirect url so the player knows what to do
                redirectUrl  = "";
                redirectUrl += SettingUtils.GetStringSetting(SETTING_SERVER_BASE_PATH) + "/" + tenantId + "/play/" + playerUrl;
                redirectUrl += "?session-token=" + sessionId;
                redirectUrl += "&session-url=" + sessionUrl;

                // Create the run url stuff using utils
                redirectUrl = RunUtils.CompleteRunUrl(redirectUrl, Guid.Parse(flowId));

                // Tell the caller to redirect back to the desired location
                response = Request.CreateResponse(HttpStatusCode.RedirectMethod, redirectUrl);
                response.Headers.Add("Location", redirectUrl);
            }
            catch (Exception exception)
            {
                throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception));
            }

            return(response);
        }