Manish Jain
Manish Jain

Reputation: 9

How to authenticate WEB API controller method using HMACSHA256

I am new to web API. I would appreciate if somebody could give me the sample code for authenticate a user by creating hash using HMACSHA256.Following is my API Controller code. I want GetCategoryNewsByFilter to be authenticated before calling it.

using NewsBytesApi.Attributes;
using NewsBytesApi.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Infrastructure;
using System.Data.Objects;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace NewsBytesApi.Controllers
{

  
    public class ValuesController : ApiController
    {
        NewsLetterDBEntities dataContext = null;
       
   

        public List<storyRepo> GetCategoryNewsByFilter()
           {
    
               dataContext = new NewsLetterDBEntities();
               List<storyRepo> lstStoryRepo = new List<storyRepo>();
               storyRepo obj = new storyRepo();
               obj.StoryContent = "ABC";
               obj.StoryHeader = "DEF";
               lstStoryRepo.Add(obj);
               return lstStoryRepo;
    
           }
              
        }
    }

Upvotes: 0

Views: 171

Answers (0)

Related Questions