private Response FacebookRequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            if (context.Request != null)
            {
                string[] perms = null;
                dynamic signedRequest;
                var fbApp = container.Resolve<IFacebookApplication>();
                if (context.TryParseFacebookSignedRequest(fbApp.AppId, fbApp.AppSecret, out signedRequest))
                {
                    if (((System.Collections.Generic.IDictionary<string, object>)signedRequest).ContainsKey("oauth_token"))
                    {
                        var fb = container.Resolve<FacebookClient>();
                        fb.AccessToken = signedRequest.oauth_token;
                        try
                        {
                            var result = (IDictionary<string, object>)fb.Get("me/permissions");
                            perms = ((IDictionary<string, object>)((IList<object>)result["data"])[0]).Keys.ToArray();
                        }
                        catch (FacebookOAuthException)
                        {
                            // access token is invalid so perms=none
                            // but don't throw exception.
                            fb.AccessToken = null;  
                        }
                    }
                }

                context.Items[CustomFacebookExtensions.FacebookPermsKey] = perms ?? new string[0];
            }

            return null;
        }