public static string GetToken(this HttpRequestBase request) { if (request == null) { return(String.Empty); } // Find Header var headerText = request.Headers[OAuthConstants.AuthorzationHeader]; if (!String.IsNullOrEmpty(headerText)) { var header = new AuthorizationHeader(headerText); if (string.Equals(header.Scheme, "OAuth", StringComparison.OrdinalIgnoreCase)) { return(header.ParameterText.Trim()); } } // Find Clean Param var token = request.Params[OAuthConstants.AuthorzationParam]; return(!String.IsNullOrEmpty(token) ? token.Trim() : String.Empty); }
public static string GetToken(this HttpRequestBase request) { if (request == null) return string.Empty; // Find Header string headerText = request.Headers[OAuthConstants.AuthorzationHeader]; log.DebugFormat("headerText={0}", headerText); if (!string.IsNullOrEmpty(headerText)) { AuthorizationHeader header = new AuthorizationHeader(headerText); log.DebugFormat("header.Scheme={0}", header.Scheme); //CG: support both Bearer and OAuth Schemes, see http://tools.ietf.org/html/rfc6750#page-5: if ("OAuth".Equals(header.Scheme, StringComparison.OrdinalIgnoreCase) || "Bearer".Equals(header.Scheme, StringComparison.OrdinalIgnoreCase)) return header.ParameterText.Trim(); } // Find Clean Param var token = request.Params[OAuthConstants.AuthorzationParam]; log.DebugFormat("token from param={0}", token); return !string.IsNullOrEmpty(token) ? token.Trim() : string.Empty; }
public static string GetToken(this HttpRequestBase request) { if (request == null) { return(string.Empty); } // Find Header string headerText = request.Headers[OAuthConstants.AuthorzationHeader]; log.DebugFormat("headerText={0}", headerText); if (!string.IsNullOrEmpty(headerText)) { AuthorizationHeader header = new AuthorizationHeader(headerText); log.DebugFormat("header.Scheme={0}", header.Scheme); //CG: support both Bearer and OAuth Schemes, see http://tools.ietf.org/html/rfc6750#page-5: if ("OAuth".Equals(header.Scheme, StringComparison.OrdinalIgnoreCase) || "Bearer".Equals(header.Scheme, StringComparison.OrdinalIgnoreCase)) { return(header.ParameterText.Trim()); } } // Find Clean Param var token = request.Params[OAuthConstants.AuthorzationParam]; log.DebugFormat("token from param={0}", token); return(!string.IsNullOrEmpty(token) ? token.Trim() : string.Empty); }
public static string GetToken(this HttpRequestBase request) { if (request == null) return String.Empty; // Find Header var headerText = request.Headers[OAuthConstants.AuthorzationHeader]; if (!String.IsNullOrEmpty(headerText)) { var header = new AuthorizationHeader(headerText); if (string.Equals(header.Scheme, "OAuth", StringComparison.OrdinalIgnoreCase)) return header.ParameterText.Trim(); } // Find Clean Param var token = request.Params[OAuthConstants.AuthorzationParam]; return !String.IsNullOrEmpty(token) ? token.Trim() : String.Empty; }