owin

ASP.NET MVC OWIN and SignalR - two Startup.cs files

好久不见. 提交于 2019-12-30 04:47:12
问题 I have a problem with my project. I use ASP.NET MVC with ASP.NET Identity 2.0 for authentication and I added SignalR to the project so now I have two Startup.cs files: First one from MVC in the root [assembly: OwinStartupAttribute(typeof(MCWeb_3SR.Startup))] namespace MCWeb_3SR { public partial class Startup { public void Configuration(IAppBuilder app) { ConfigureAuth(app); } } } And SignalR one in AppCode folder [assembly: OwinStartup(typeof(SignalRChat.Startup))] namespace SignalRChat {

Twitter external login with Owin gives HTTP 403 (Forbidden)

故事扮演 提交于 2019-12-30 04:37:08
问题 ASP.NET MVC 5 Project. Owin Version 4.0.0.0 Startup.Auth app.UseTwitterAuthentication( consumerKey: "somekey", consumerSecret: "someSecretKey"); The exception happened in the ExternalLogin method Response status code does not indicate success: 403 (Forbidden). Here are the callback URLs FYI: the website is real and it is working without problem, The Twitter Login was working a couple of weeks ago, but Now, suddenly, started to fail with the previous error. StackTrace [HttpRequestException:

Manually decode OAuth bearer token in c#

你离开我真会死。 提交于 2019-12-30 04:22:06
问题 In my Web Api 2.2 OWIN based application I have a situation where I manually need to decode the bearer token but I don't know how to do this. This is my startup.cs public class Startup { public static OAuthAuthorizationServerOptions OAuthServerOptions { get; private set; } public static UnityContainer IoC; public void Configuration(IAppBuilder app) { //Set Auth configuration ConfigureOAuth(app); ....and other stuff } public void ConfigureOAuth(IAppBuilder app) { OAuthServerOptions = new

Customize OWIN/OAuth HTTP status code when rejecting a token request

时光毁灭记忆、已成空白 提交于 2019-12-30 04:00:10
问题 I've derived OAuthAuthorizationServerProvider in order to validate both clients and resource owners. When I validate resource owners I find their credentials aren't valid, I call context.Rejected() , and HTTP response comes with HTTP/400 Bad Request status code while I would expect HTTP/401 Unauthorized . How can I customize OAuthAuthorizationServerProvider 's response HTTP status codes? 回答1: This is how we override the OwinMiddleware...first we created our own middleware on top of Owin...I

owin cors or web api cors

送分小仙女□ 提交于 2019-12-30 03:55:08
问题 there are 100s of question on CORS on web-api, and on how to enable CORS, there is a different answer each one provides. I am so confused and dont know which answer is correct. And the problem is none of the answers actually explains it point wise, what each line of code does, so that I can understand and solve my problem rather than copy-pasting the code. anyways, the question is: I am using asp.net web api 2 using owin. And i need to enable CORS. how do I do it? There is cors settings for

Resolving dependencies in OWIN WEB API Startup.cs with ninject

…衆ロ難τιáo~ 提交于 2019-12-29 18:43:52
问题 I have a Web Api 2 App, with two classes that both depend on another class, and i'm using ninject to resolve the dependancies. public class AuthorizationServerProvider : OAuthAuthorizationServerProvider { private IUserService _userService; public AuthorizationServerProvider(IUserService userService) { _userService = userService; } } public class RefreshTokenProvider : IAuthenticationTokenProvider { private IUserService _userService; public RefreshTokenProvider(IUserService userService) {

How to link exceptions to requests in Application Insights on Azure?

。_饼干妹妹 提交于 2019-12-29 17:47:30
问题 We are using Owin on Azure for a REST service, and have to report to Application Insights directly. We want to log exceptions and requests. Right now we have this: using AppFunc = Func<IDictionary<string, object>, Task>; public class InsightsReportMiddleware { readonly AppFunc next; readonly TelemetryClient telemetryClient; public InsightsReportMiddleware(AppFunc next, TelemetryClient telemetryClient) { if (next == null) { throw new ArgumentNullException("next"); } this.telemetryClient =

How to link exceptions to requests in Application Insights on Azure?

杀马特。学长 韩版系。学妹 提交于 2019-12-29 17:47:01
问题 We are using Owin on Azure for a REST service, and have to report to Application Insights directly. We want to log exceptions and requests. Right now we have this: using AppFunc = Func<IDictionary<string, object>, Task>; public class InsightsReportMiddleware { readonly AppFunc next; readonly TelemetryClient telemetryClient; public InsightsReportMiddleware(AppFunc next, TelemetryClient telemetryClient) { if (next == null) { throw new ArgumentNullException("next"); } this.telemetryClient =

How to link exceptions to requests in Application Insights on Azure?

左心房为你撑大大i 提交于 2019-12-29 17:46:05
问题 We are using Owin on Azure for a REST service, and have to report to Application Insights directly. We want to log exceptions and requests. Right now we have this: using AppFunc = Func<IDictionary<string, object>, Task>; public class InsightsReportMiddleware { readonly AppFunc next; readonly TelemetryClient telemetryClient; public InsightsReportMiddleware(AppFunc next, TelemetryClient telemetryClient) { if (next == null) { throw new ArgumentNullException("next"); } this.telemetryClient =

How to get Facebook first and last name values using ASP.NET MVC 5 and OWIN?

ⅰ亾dé卋堺 提交于 2019-12-29 14:17:11
问题 I know that a 'Name' field is provided, but I would prefer to access the first and last names explicitly. Can someone help with this? I'm still wrapping my head around ASP.Net MVC. 回答1: In your Startup.Auth.cs ConfigureAuth(IAppBuilder app) method, set the following for Facebook: var x = new FacebookAuthenticationOptions(); x.Scope.Add("email"); x.AppId = "*"; x.AppSecret = "**"; x.Provider = new FacebookAuthenticationProvider() { OnAuthenticated = async context => { context.Identity.AddClaim