Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new IAuthProvider[] { new BasicAuthProvider(new AppSettings()), }));
Plugins.Add(new RegistrationFeature());
container.Register<ICacheClient>(new MemoryCacheClient());
var userRepository = new InMemoryAuthRepository();
container.Register<IUserAuthRepository>(userRepository);
string hash;
string salt;
new SaltedHash().GetHashAndSaltString("password", out hash, out salt);
userRepository.CreateUserAuth(new UserAuth
{
Id = 1,
DisplayName = "JoeUser",
Email = "joe@user.com",
UserName = "hal",
FirstName = "Joe",
LastName = "User",
PasswordHash = hash,
Salt = salt,
Roles = new List<string> { RoleNames.Admin },
//Permissions = new List<string>{"GetStatus"}
}, "password");
これはグローバルな asax ファイルで、このコードで認証します
[Route("/ClientList/", "POST")]
[ Authenticate]
public class ClientGet
{
public string username { get; set; }
public string password { get; set; }
}
しようとするとモノタッチ段階で
client = new JsonServiceClient ("http://sampleurl.com/api/authenticate/Basic?format=json") {
UserName = "hal",
Password = "password"
};
または client = new JsonServiceClient (" http://sampleurl.com/api ) {Username="Hal", Password="password");
リクエストタイムアウトの問題が発生します
アップデートはありますか?
ありがとう