1

I am appending a token to every request I make to my REST service. For example, to get information about a user, you would do:

/Service.svc/users/12174?auth_token=138eac01291378f

But to achieve this, I need to do this:

[OperationContract]
public interface Foo
{
    [OperationContract]
    [WebInvoke (UriTemplate = "/users/{id}/?auth_token={token}")]
    UserInfo GetUserInfo (int id, string token);

    [OperationContract]
    [WebInvoke (UriTemplate = "/users/delete/{id}/?auth_token{token}")]
    void DeleteUser (int id, string token);
}

Not only do I need to set the UriTemplate to accept the access token, but I must handle it in each method seperately.

Is there a way to handle this (authentication) before the methods get called? So I would be able to handle authentication globally, without passing the token to each method separately.

mishmash
  • 4,422
  • 3
  • 34
  • 56
  • I think you want to look at: http://stackoverflow.com/questions/4398584/how-to-manage-sessions-in-restful-wcf-service - it will not be a REST service if you want to save the state of the client (authtoken + timeout + who the user for the token is). Can't you use normal WCF service with sessions? – milanio Apr 03 '13 at 22:33

0 Answers0