title: Owin hosted web app using Token authentication
body: <p>I am trying to create an owin web app using token authentication, my startup does not have any special setup like the example in </p>
  
  <p><a href="https://github.com/NancyFx/Nancy/wiki/Token-Authentication" rel="nofollow">https://github.com/NancyFx/Nancy/wiki/Token-Authentication</a></p>
  
  <pre><code>public class Bootstrapper : DefaultNancyBootstrapper
  {
      protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
      {
          TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve&lt;ITokenizer&gt;()));
      }
  }
  </code></pre>
  
  <p>mine is simply</p>
  
  <pre><code>public void Configuration(IAppBuilder app)
  {
      app.UseNancy();
  }
  </code></pre>
  
  <p>I have the module defined like</p>
  
  <pre><code>public HomeModule(ITokenizer tokenizer)
  {
  
      Post["/login"] = _ =&gt;
      {
          DefaultUserIdentityResolver resolver = new DefaultUserIdentityResolver();
          //var userName = (string)this.Request.Form.Username;
          //var password = (string)this.Request.Form.Password;
  
          var claims = new List&lt;string&gt; { "admin", "poweruser" };
  
          var userIdentity = resolver.GetUser("ross", claims, Context);
          if (userIdentity == null)
          {
              return HttpStatusCode.Unauthorized;
          }
  
          var token = tokenizer.Tokenize(userIdentity, Context);
  
          return new
          {
              Token = token,
          };
      };
  }
  </code></pre>
  
  <p>Not much just yet I know but when when I get to tokenize I get an exception of the type Nancy.ErrorHandling.RouteExecutionEarlyExitException which really doesnt have anything in the message or stack trace to indicate the issue.</p>
  
  <p>I am currently hosting over http in casini on .NET 4.5.1   </p>
  
  <p>Any pointers would be appreciated</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Message is:</p>
  
  <pre><code>Exception of type 'Nancy.ErrorHandling.RouteExecutionEarlyExitException' was thrown.
  
  Stack trace is:
     at Nancy.Authentication.Token.Tokenizer.Tokenize(IUserIdentity userIdentity, NancyContext context)
     at Samaritan.Hosting.HttpServices.HomeModule.&lt;&gt;c__DisplayClass11.&lt;.ctor&gt;b__7(Object _) in c:\src\DukeSoftware\Samaritan\Main\Samaritan.Hosting.HttpServices\HomeModule.cs:line 39
     at CallSite.Target(Closure , CallSite , Func`2 , Object )
     at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
     at Nancy.Routing.Route.&lt;&gt;c__DisplayClass4.&lt;Wrap&gt;b__3(Object parameters, CancellationToken context)
  </code></pre>
  
  <p>I tried setting up the startup.cs like this</p>
  
  <pre><code>public class Startup
  {
      public void Configuration(IAppBuilder app)
      {
          app.UseNancy();
      }
  }
  
  public class Bootstrapper : DefaultNancyBootstrapper
  {
      protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
      {
          TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve&lt;ITokenizer&gt;()));
      }
  }
  </code></pre>
  
  <p>but I got the following exception</p>
  
  <pre><code>{"Located multiple bootstrappers:\r\n - Samaritan.Hosting.HttpServices.BootStarapper\r\n - Samaritan.Hosting.HttpServices.Bootstrapper\r\n\r\nEither remove unused bootstrapper types or specify which type to use."}
  </code></pre>
  
  <p>So I removed the bootsrapper and just left Startup. An instantiated tokenizer seems to be passed into the module when you declare the constructor  public <code>HomeModule(ITokenizer tokenizer)</code> 
  So I didnt think the creation of the tokenizer was a problem</p>