如何使用 OAuth 2.0 访问 Basecamp 用户详细信息
How to get access to Basecamp user detail using OAuth 2.0
我正在尝试使用 Base Camp 登录,因为 MVC 项目使用 Google facebook 等 我怎样才能使用我的 BaseCamp 凭证登录
有很多方法可以实现,但是旧的是黄金使用 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;
}
}
就是这样希望这有帮助
我正在尝试使用 Base Camp 登录,因为 MVC 项目使用 Google facebook 等 我怎样才能使用我的 BaseCamp 凭证登录
有很多方法可以实现,但是旧的是黄金使用 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;
}
}
就是这样希望这有帮助