如何使用OAuth 2.0访问Basecamp用户详细信息

时间:2015-03-26 17:41:59

标签: asp.net-mvc basecamp

我正在尝试使用大本营登录,因为MVC项目使用Google facebook等我如何使用我的basecamp凭证登录

1 个答案:

答案 0 :(得分:1)

有很多方法可以实现,但旧的是黄金使用 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;
    }
}

这就是希望这有助于

相关问题