My api client code sends an authentication token in the querystring like:
www.example.com/api/user/get/123?auth_token=ABC123
I\'m using Mvc
In the OnActionExecuting method of a filter, you can access the query string and parse it like this to get the token.
var queryString = actionContext.Request.RequestUri.Query;
if(!String.IsNullOrWhiteSpace(queryString))
{
string token = HttpUtility.ParseQueryString(
queryString.Substring(1))["auth_token"];
}
But then, is passing a token in query string a good practice? Probably not, but it is up to you. HTTP header could be a better option since query string can get logged and cached.