我正在尝试使用大本营登录,因为MVC项目提供了使用Google、facebook等,如何使用我的basecamp凭证登录?
发布于 2015-03-26 19:55:28
有很多实现方法,但是旧的是黄金,使用BasecampRestAPI非常容易实现,例如:让我们先对用户进行身份验证。
public static bool Authenticate(string username, string password)
{
BaseCamp objCamp = BaseCamp.GetInstance("https://CompanyName.basecamp.com", username, password);
// as we authenticated, therefore pass username after formatting it i.e. converting "Khawaja.Atteeq" to "Khawaja Atteeq" format
string user = username.Split('@')[0].Replace('.', ' ');
user = new CultureInfo("en").TextInfo.ToTitleCase(user.ToLower());
// session if necessary.
HttpContext.Current.Session["UserID"] = user;
return true;
}现在让我们转到登录页面。
protected void SignIn_Click(object sender, EventArgs e)
{
if (Authenticate(Username.Text.Trim(), Password.Text))
{
Response.Redirect("~/");
}
else
{
Error.Visible = true;
}
}希望这能帮上忙
https://stackoverflow.com/questions/29285294
复制相似问题