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.