title: OData - Data Service Simple Authentication
body: <p>I would like to add simple authentication to Data Services, for now only to restrict access for particular applications by simple token.</p>
  
  <p>I don't need Domain Authentication or Forms authentication.</p>
  
  <p>I read a lot about authentication here:</p>
  
  <p><a href="http://franssenden.wordpress.com/2010/06/14/custom-security-odata-service-wcf-data-services/" rel="nofollow noreferrer">http://franssenden.wordpress.com/2010/06/14/custom-security-odata-service-wcf-data-services/</a></p>
  
  <p><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/06/03/10482.aspx" rel="nofollow noreferrer">http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/06/03/10482.aspx</a></p>
  
  <p><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/01/15/10119.aspx" rel="nofollow noreferrer">http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/01/15/10119.aspx</a></p>
  
  <p><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/01/10/10100.aspx" rel="nofollow noreferrer">http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/01/10/10100.aspx</a></p>
  
  <p>Unfortunately it all demands a loooot of work. 
  Most of all creating custom IHttpModule.
  There should be more simple solution.</p>
  
  <p>I know that when I create object context on the client (WPF) I can add Credentials. </p>
  
  <pre><code>Uri uri = new Uri("http://localhost/myapp/odata.svc");
  
  MyEntities ent= new MyEntities (uri);
  ent.Credentials = new NetworkCredential("token", "zx5as9vxc5sa9h0vb6523cv56");
  </code></pre>
  
  <p>But where can I read them (without implementation of custom IHttpModule)?</p>
  
  <p>I thought that I can use something in class that is implementation of Data Service for example:</p>
  
  <pre><code>protected override void OnStartProcessingRequest(ProcessRequestArgs args)
  {
   string cred = args.OperationContext.AbsoluteRequestUri.UserInfo;
  }
  </code></pre>
  
  <p>I'm not familiar with UserInfo but description for it stands "Gets the user name, password, ...)</p>
  
  <p>So I have two main questions:</p>
  
  <ol>
  <li><p>Where can I read Credentials included by typing ent.Credentials = new NetworkCredential("token", "zx5as9vxc5sa9h0vb6523cv56");</p></li>
  <li><p>Where can I (if I can) set UserInfo on the client app and use it in OnStartProcessingRequest method.</p></li>
  </ol>
  
  <p>Regards,
  Daniel Skowroński</p>