static string GetToken(RavenBaseApiController controller) { const string bearerPrefix = "Bearer "; var auth = controller.GetHeader("Authorization"); if (auth == null) { auth = controller.GetCookie("OAuth-Token"); if (auth != null) { auth = Uri.UnescapeDataString(auth); } } if (auth == null || auth.Length <= bearerPrefix.Length || !auth.StartsWith(bearerPrefix, StringComparison.OrdinalIgnoreCase)) { return(null); } var token = auth.Substring(bearerPrefix.Length, auth.Length - bearerPrefix.Length); return(token); }
static string GetToken(RavenBaseApiController controller) { const string bearerPrefix = "Bearer "; var auth = controller.GetHeader("Authorization"); if (auth == null) { auth = controller.GetCookie("OAuth-Token"); if (auth != null) auth = Uri.UnescapeDataString(auth); } if (auth == null || auth.Length <= bearerPrefix.Length || !auth.StartsWith(bearerPrefix, StringComparison.OrdinalIgnoreCase)) return null; var token = auth.Substring(bearerPrefix.Length, auth.Length - bearerPrefix.Length); return token; }