我需要使用第三方令牌作为身份验证的方式。我在家庭控制器中获取令牌,并且需要能够将其发送到我的WebAPI控制器(它是使用Backbone的SPA应用程序)。有没有办法做到这一点?
编辑:
相关代码:
public ActionResult Index(string projectId, int companyId, bool isCompanyAdmin)
{
// if not a valid user return error
var validate = new Validate().ValidateContext(HttpContext,
"Key", "Secret");
if (!validate.IsValidated) return View(Constants.ValidationFailed);
// The info validated, so now I can set it to authorized
// put code here for doing it
//Get the model for the user
try
{
var model = ConvertToVM(_smsRepository.GetCompany(companyId, projectId));
}
catch (ProviderIncompatibleException)
{
// connection string wrong
return View(Constants.ConnectionFailed);
}
catch (Exception e)
{
// catch all
return View(Constants.DatabaseError);
}
//create and send through the view model that determines what view the user will get
return View(model);
}
好的,我在Home Controller上输入了索引方法。就像我说的那样,我们调用传入上下文的第三方API,客户端密钥和客户端密钥来验证我们的身份。我可以在家庭控制器中添加一个Bearer令牌吗?或者以其他方式将http上下文传递给OWiN并使用一些自定义逻辑来添加令牌,如果validate.IsValidated为true?它需要与WebAPI一起使用。