asp.net-web-api2

OAuth Client Credential Flow - Refresh Tokens

[亡魂溺海] 提交于 2020-01-02 07:53:29
问题 The Scenario I've recently built an ASP.NET WEB API , and have protected its resources using OAuth Bearer Access Tokens. I've used the Client_Credentials Flow, as it will be accessed by clients as opposed to users. Here's the thing, when a client has successfully provided the client_id and the client_secret they receive a response like the following :- { "access_token": "<Access Token>", "token_type": "bearer", "expires_in": 1199, "refresh_token": "<Refresh Token>" } Refresh Tokens. Not

Resource Description on Web API Help page is showing “None.”

风格不统一 提交于 2020-01-02 05:15:13
问题 I'm having trouble figuring out how to get the Help page in my Web Api to show anything for Resource Description other than None. It has IHttpActionResult linked and then "None." after that. I got my samples working by adding config.SetActualResponseType(typeof(ComplexType), "Controller", "Action"); to HelpPageConfig.cs. My controller looks like this: /// <summary> /// My description /// </summary> [Route("MyRoute")] public IHttpActionResult Get() { try { //throw new Exception("TEST"); return

OData v4 Function always returns 404

心不动则不痛 提交于 2020-01-02 03:37:10
问题 Trying to move from OData v3 to OData v4 . Why do I keep getting a 404 when trying to use OData Functions ? Web API Config: ODataModelBuilder builder = new ODataConventionModelBuilder(); //etc builder.EntitySet<LocalizableString>("LocalizableStringApi"); //etc var getComparitiveTableFunction = builder.EntityType<LocalizableString>().Collection.Function("GetComparitiveTable"); getComparitiveTableFunction.Parameter<string>("cultureCode"); getComparitiveTableFunction.ReturnsCollection

Web API 2 requires trailing slash for custom attribute routing to work

馋奶兔 提交于 2020-01-02 02:37:06
问题 I have created a Web API 2 project and although the APIs work fine, I must enter a trailing slash for them to do so. This results in a 404 http://www.myURL.com/api/v1/get/addressfromlatlong/UK/50.9742794/-0.1146699 This shows the JSON response as intended http://www.myURL.com/api/v1/get/addressfromlatlong/UK/50.9742794/-0.1146699/ I have another controller with a custom action that works fine. The only difference is that this has one parameter that is an integer... It seems to be something to

Web Api 2 HttpContext or HttpActionContext

牧云@^-^@ 提交于 2020-01-02 02:32:06
问题 What is the difference between the following two ways of accessing the principle via an AuthorizeAttribute implementation? Using HttpContext : protected override bool IsAuthorized(HttpActionContext actionContext) { return HttpContext.Current.User.IsInRole("DemoRole"); } Using HttpActionContext : protected override bool IsAuthorized(HttpActionContext actionContext) { return actionContext.RequestContext.Principal.IsInRole("DemoRole"); } 来源: https://stackoverflow.com/questions/28235979/web-api-2

OAuth access and refresh token control / management on user password change

╄→гoц情女王★ 提交于 2020-01-01 19:42:28
问题 We are in the process of developing a in house mobile application and web api. We are using asp.net web api 2 with asp.net Identy 2 OAuth. I have got the api up and running and giving me a bearer token. However I want to slightly modify the process flow to something like along the lines of this: App user logs in to api with username and password. App receives Refresh-token which is valid for 30 days. App then requests an access token providing the api with the refresh token. ( Here I want to

OAuth access and refresh token control / management on user password change

删除回忆录丶 提交于 2020-01-01 19:41:13
问题 We are in the process of developing a in house mobile application and web api. We are using asp.net web api 2 with asp.net Identy 2 OAuth. I have got the api up and running and giving me a bearer token. However I want to slightly modify the process flow to something like along the lines of this: App user logs in to api with username and password. App receives Refresh-token which is valid for 30 days. App then requests an access token providing the api with the refresh token. ( Here I want to

WEB API 2 : get profile data during oauth RegisterExternal (facebook)

浪子不回头ぞ 提交于 2020-01-01 13:21:50
问题 In the out of the box ASP.NET WEB API oAuth implementation after a new user calls: GET api/Account/ExternalLogins?returnUrl=%2F&generateState=true user is redirected to external log in (in my case Facebook) resulting in a token that they use for registration (out of the box code bellow) // POST api/Account/RegisterExternal [OverrideAuthentication] [HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)] [Route("RegisterExternal")] public async Task<IHttpActionResult> RegisterExternal(

WEB API 2 : get profile data during oauth RegisterExternal (facebook)

北战南征 提交于 2020-01-01 13:19:08
问题 In the out of the box ASP.NET WEB API oAuth implementation after a new user calls: GET api/Account/ExternalLogins?returnUrl=%2F&generateState=true user is redirected to external log in (in my case Facebook) resulting in a token that they use for registration (out of the box code bellow) // POST api/Account/RegisterExternal [OverrideAuthentication] [HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)] [Route("RegisterExternal")] public async Task<IHttpActionResult> RegisterExternal(

Possible to post ODataQueryOptions from the Http Request body?

淺唱寂寞╮ 提交于 2020-01-01 10:02:10
问题 I'm implementing a Web API interface to support some fairly complex queries to run against it and have run up against an issue with the maximum request URI length. The definition of my Web API method looks like this (using Automapper to perform the DTO projections): public IQueryable<ReportModel> Get(ODataQueryOptions<Report> queryOptions) { var query = DbContext.Query<Report>(); return (queryOptions.ApplyTo(query) as IQueryable<Report>).WithTranslations().Project(MappingEngine).To