Bazı benzer sorunlar hakkında konuşarak birkaç yazı okudum, ancak bunu çalışmak için henüz yapmıyorum.CORS
ChallengeResult'u üreten ve OWIN ile kimlik doğrulaması için akışı başlatan "Account/ExternalLogin" ajax yapıyorum.
Bu benim Startup
sınıftır:
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
// Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseCors(CorsOptions.AllowAll);
var goath2 = new Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationOptions
{
ClientId = "myclientid",
ClientSecret = "mysecret",
Provider = new Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationProvider
{
OnApplyRedirect = context =>
{
string redirect = context.RedirectUri;
const string Origin = "Origin";
const string AccessControlAllowOrigin = "Access-Control-Allow-Origin";
// origin is https://localhost:44301
var origin = context.Request.Headers.GetValues(Origin).First();
// header is present
var headerIsPresent = context.Response.Headers.ContainsKey(AccessControlAllowOrigin);
context.Response.Redirect(redirect);
}
}
};
app.UseGoogleAuthentication(goath2);
}
}
ı ararken CORS hattı app.UserCors(CorsOptinos.AllowAll);
nereye destekleyen Ve ben OnApplyRedirect
olay müdahale çünkü başlık yanıtı ekleniyor biliyoruz ve etkinleştirme ediyorum orijin, 'localhost: 443001' olarak ayarlanmıştır ve 'Access-Control-Allow-Origin' başlığı da bu değere ayarlanmıştır.
XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxx No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin
https://localhost:44301
is therefore not allowed access.
Burada eksik Ne: tepkisi aşağıdaki hatayı sahip istemciye gönderilir Yine
.
Tüm bu "el ile" (doğrudan istemciden google istemek ...) yapmak için bir iş bulabilirim ama gerçekten OWIN ara katmanını kullanmak istiyorum.