2016-07-25 58 views
0

我下面这个教程,以便从我的移动服务器提供的用户名/密码认证:http://www.newventuresoftware.com/blog/custom-authentication-with-azure-mobile-apps用户名/为天青应用服务密码验证:移动

我的服务器端代码是这样的,使用Microsoft.Azure .Mobile.Server.Login NuGet包:

private JwtSecurityToken GetAuthenticationTokenForUser(string username) 
{ 
    var claims = new[] { new Claim(JwtRegisteredClaimNames.Sub, username) }; 
    var signingKey = Environment.GetEnvironmentVariable("WEBSITE_AUTH_SIGNING_KEY"); 
    var issuer = Request.RequestUri.GetLeftPart(UriPartial.Authority); 
    return AppServiceLoginHandler.CreateToken(claims, signingKey, issuer, issuer, TimeSpan.FromHours(24)); 
} 

这产生了一个奇怪的编译器错误。对AppServiceLoginHandler.CreateToken的调用打破了编译器的明显误导性消息:

引用类型'JwtSecurityToken'声明它在'System.IdentityModel.Tokens.Jwt'中定义,但找不到它。

类型System.IdentityModel.Tokens.Jwt.JwtSecurityToken由Intellisense提取。重建项目并没有帮助。无论我做什么,这条线都会破坏构建。

+0

您是否安装了正确的nuget ref: JeremyBP

+0

请找到这个工作示例:https://github.com/Apptracktive/AptkAma/tree/master/AptkAma.Sample/AptkAma.Sample.Backend – JeremyBP

回答

1

更新到最新的nuget版本5.0.0时出现此错误。恢复到4.0.2.2可以修复它。 (指System.IdentityModel.Tokens.Jwt nuget包)