Closed xenOIvan closed 9 years ago
Did you set the Caption? We need the middleware to work the same way all the other katana authentication middleware works.
Caption? no. but i don't set any for FB o G+ either. how should i do that? i even google this thing and there is no clue about Caption. how could i set caption? how other provider work?
Caption: https://github.com/IdentityServer/IdentityServer3/blob/master/source/Host/Startup.cs#L96
Ths Caption is how we set the text in the login button.
i can see buttons, when i hit it, it's redirect me to /RegisterAccount witch is my endpoint for user registration, this end point validate and then challenge the request in a exact same way that work in AuthenticationController/LoginExternal endpoint in core project, i also can auth user with fb,g+ & instagram, but i encounter silly problems with yahoo (get exception) as below:
An unhandled exception occurred while processing the request. HttpRequestException: Response status code does not indicate success: 401 (Forbidden).
System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
Stack Query Cookies Headers Environment
HttpRequestException: Response status code does not indicate success: 401 (Forbidden).
System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
Owin.Security.Providers.Yahoo.YahooAuthenticationHandler.<ObtainRequestTokenAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Owin.Security.Providers.Yahoo.YahooAuthenticationHandler.<ApplyResponseChallengeAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.<ApplyResponseCoreAsync>d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.<ApplyResponseAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationHandler.<TeardownAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Thinktecture.IdentityServer.Core.Configuration.Hosting.AutofacContainerMiddleware.<Invoke>d__4.MoveNext() in AutofacContainerMiddleware.cs
throw;
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Owin.UseCookieAuthenticationExtension.<>c__DisplayClass6.<<ConfigureCookieAuthentication>b__4>d__8.MoveNext() in ConfigureCookieAuthenticationExtension.cs
await next();
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Cors.CorsMiddleware.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Owin.ConfigureIdentityServerBaseUrlExtension.<>c__DisplayClass1.<<ConfigureIdentityServerBaseUrl>b__0>d__3.MoveNext() in ConfigureIdentityServerBaseUrlExtension.cs
await next();
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Owin.ConfigureRequestIdExtension.<<ConfigureRequestId>b__0>d__2.MoveNext() in ConfigureRequestIdExtension.cs
await next();
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Thinktecture.IdentityServer.Core.Configuration.Hosting.RequireSslMiddleware.<Invoke>d__0.MoveNext() in RequireSslMiddleware.cs
await _next(env);
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Mapping.MapMiddleware.<Invoke>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.Owin.Diagnostics.ErrorPageMiddleware.<Invoke>d__0.MoveNext()
BTW i think the forbidden error is because at the end of method i (same as you) write this :
_context.Authentication.Challenge(authProp, provider);
return Unauthorized();
but i assume that owin will change the response status code to 302....
i create another app (the pre on is Website application, the new one is mobile application) in yahoo, and change my code to this and everything work fine.
var yahoo = new YahooAuthenticationOptions()
{
SignInAsAuthenticationType = signInAsType,
AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive,
BackchannelTimeout = TimeSpan.FromSeconds(60),
Caption = "Yahoo",
AuthenticationType = "Yahoo",
ConsumerKey = "*******",
ConsumerSecret = "*******",
};
app.UseYahooAuthentication(yahoo);
So as I alluded to above, if the yahoo authN middleware doesn't implement the same pattern as the rest of the Microsoft authN middleware then we might not be able to interop with it. Most of what I'm talking about is the work that the AuthenticationHandler base class performs. Check to see if the yahoo implementation is using that base class.
So did you get it to work, or determine if the yahoo middleware supports the Microsoft approach?
I have the same problem and i think the problem is from
ConsumerKey = "*******",
ConsumerSecret = "*******",
but i don't find one good tutorial how to create this key on yahoo, i find only this http://www.oauthforaspnet.com/providers/yahoo/ but is not complete.
Can anyone help us? if someone have yahoo provider implemented.
To register a web app in Yahoo you will need to specify a callback domain, but unfortunately you cannot specify localhost as the callback domain. Yahoo also validates that the domain is correct, so even if you register a domain other that localhost, when you test the application locally, the ASP.NET Identity runtime will specify the callback URL as being on the localhost domain, and Yahoo will not allow this.
This means that you will run into some issues when wanting to register and test an application locally on you computer. There are 2 ways around this.
The first is to use a tool like Ngrok to tunnel traffic from a “proper” domain which is valid according to Yahoo, to your localhost. This requires reconfiguring IIS Express to recognize that domain, and also reconfiguring your project to use that new URL. There is a blog post on the Twilio website entitled Configure Windows for Local Webhook Testing Using ngrok which describes how to do it
The second (and easier) way is that when registering the application in Yahoo, you specify the application type as “Installed Application” instead of “Web Application”. If you do this you do not need to have a callback domain for an installed application.
For the sake of simplicity I will use the second approach as it works just fine, and is much simpler. I will only suggest using this for local development. For your production website you need to register the application as a “Web Application” and specify a correct callback domain.
you can find this good article with step by step tutorial here: http://www.oauthforaspnet.com/providers/yahoo/guides/aspnet-mvc5/
I have same difficulty with Microsoft LiveID. unfortunately i cannot find any alternative way for Microsoft ouath to test it from localhost, so i have to deffer it to release time and test it on running app on actual domain
I have my idsrv3 hosted on one sub-domain and port like this: https://mysub.site.ro:6165/identity this is not supported by yahoo and Microsoft? i have the some problem like you also on Microsoft LiveID
i find this key here: https://github.com/TapedeckNinja/FantasyProject/blob/1adf090bd0aac0450a3d0363ac164c82a48a3b12/TheFantasyProject.Web.Charts/App_Start/Startup.Auth.cs and this works, why ? this app work on my server and the application created by me don't work.
and there is one tricky other thing for yahoo, you MUST select at least on of the API Access for your client application in yahoo.
to do this : https://developer.apps.yahoo.com >> goto your project >> under Permissions section >> check Contacts (readonly) be consider that after this, your Consumer Key & Consumer Secret is changed, so don't forget to update them.
@xenOIvan Glad you got it working and thanks for providing the details for getting it setup.
Like you say is my app on yahoo but don't work. On the Callback Domain option i can't set port number. But why the key from TapedeckNinja works? I have checked Contacts (readonly) .. is need to check Read/Write ?
Is important Application Type ? i set this to Web Application. need to set app to Installed Application ?
Why not set a dev-domain in your hosts file on your local env and use that when testing locally?
dev.yourdomain.com 127.0.0.1
and then register some callbackurl using that domain in Yahoo?
i will try this
hi, i can connect to Facebook & Google using thinteckture identity server v.3, but when i add yahoo provider it get an error before redirect user to yahoo conset. this is my code:
the same codes work just fine to Facebook and Google, so were is my problem?