我下面這個教程,以便從我的移動服務器提供的用戶名/密碼認證: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提取。重建項目並沒有幫助。無論我做什麼,這條線都會破壞構建。
您是否安裝了正確的nuget ref: –
JeremyBP
請找到這個工作示例:https://github.com/Apptracktive/AptkAma/tree/master/AptkAma.Sample/AptkAma.Sample.Backend – JeremyBP