जबकि निम्नलिखित ट्यूटोरियल Create a RESTful API with authentication using Web API and Jwt मैं मुसीबत को संकलित करने के CustomJwtFormat
वर्ग हो रही हूँ:'Microsoft.IdentityModel.Tokens.SymmetricSecurityKey' से परिवर्तित नहीं कर सकते करने के लिए 'Microsoft.IdentityModel.Tokens.SigningCredentials'
using System.IdentityModel.Tokens;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.DataHandler.Encoder;
using Thinktecture.IdentityModel.Tokens;
namespace BooksAPI.Identity
{
public class CustomJwtFormat : ISecureDataFormat<AuthenticationTicket>
{
private static readonly byte[] _secret =
TextEncodings.Base64Url.Decode(ConfigurationManager.AppSettings["secret"]);
private readonly string _issuer;
public CustomJwtFormat(string issuer)
{
_issuer = issuer;
}
public string Protect(AuthenticationTicket data)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
var signingKey = new HmacSigningCredentials(_secret);
var issued = data.Properties.IssuedUtc;
var expires = data.Properties.ExpiresUtc;
return new JwtSecurityTokenHandler().WriteToken(
new JwtSecurityToken(_issuer, null, data.Identity.Claims,
issued.Value.UtcDateTime, expires.Value.UtcDateTime, signingKey));
}
public AuthenticationTicket Unprotect(string protectedText) {
throw new NotImplementedException();
}
}
}
त्रुटि का निर्माण मैं हो रही है:
'Thinktecture.IdentityModel.Tokens.HmacSigningCredentials' से कनवर्ट नहीं कर सकता करने के लिए 'Microsoft.IdentityModel.Tokens.SigningCredential s '
इस के लिए खोज करने के बाद मैं इस अतः पद पाया:
ASP.NET v5 Multiple SigningCredentials
मैं जवाब पोस्ट में लेकिन कोई लाभ नहीं हुआ सिफारिश की कोशिश की है। मैं लिंक का पालन:
Ambiguous reference issue (Microsoft.AspNet.Identity & Microsoft.AspNet.Identity.Core)
लेकिन फिर भी संघर्ष देख रहा हूँ। मुझे किस पैकेज और नेमस्पेस संयोजन का उपयोग करना चाहिए?