I've tried to implement JWT/OAuth With Identity 2.1 in single Application MVC 5 in better words OAuth server and the resource server are the same, Since i am new to the concept i am doing as this Tutorial has done so. At the moment I am stuck with Getting signingCredentials going.
In Code below, When i Reference it as System.IdentityModel.Token i can't use it in JwtSecurityToken. When i Reference it as Microsoft.IdentityModel.Token the SigningCredentials only takes only 2 parameters, but i have to define 3 as shown in tutorial. Would you please recommend a way to solve this issue? thank you in advance.
What I have tried:
public string Protect(AuthenticationTicket data)
{
if (data == null) throw new ArgumentNullException("data");
var issuer = "localhost";
var audience = "all";
var key = Convert.FromBase64String("UHxNtYMRYwvfpO1dS5pWLKL0M2DgOj40EbN4SoBWgfc");
var now = DateTime.UtcNow.AddHours(3.5);
var expires = now.AddMinutes(_options.AccessTokenExpireTimeSpan.TotalMinutes);
var signingCredentials = new System.IdentityModel.Tokens.SigningCredentials(
new InMemorySymmetricSecurityKey(key),
SignatureAlgorithm,
DigestAlgorithm);
var token = new JwtSecurityToken(issuer, audience, data.Identity.Claims,
now, expires, signingCredentials);
return new JwtSecurityTokenHandler().WriteToken(token);
}