1
我将WebApi2添加到我的MVC应用程序中,并且可以通过浏览器成功调用我的API。如果用户未通过身份验证,则会显示我的标准登录屏幕,然后运行。如何登录并将令牌传递给WebAPI2
但我真的很想把api称为一个来自移动应用的REST api。我在搜索时添加了以下代码来启动。但我不知道如何实际通过URL登录,或在我的通话中传递和使用令牌。
我尝试了例如myurl/api/Account/ExternalLogin,但我得到无效请求。
PublicClientId = "self";
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
// Note: Remove the following line before you deploy to production:
AllowInsecureHttp = true
};
所以现在的问题是,如何我实际使用REST API调用,或者我需要把额外的代码在我的控制器。