Closed kyi87 closed 4 months ago
I found the solution, problem as in the server. I had to add the JwtBearerEvents in my AddJwtBearer Method:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = "https://securetoken.google.com/" + firebaseConfig.AppId;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = "https://securetoken.google.com/" + firebaseConfig.AppId,
ValidateAudience = true,
ValidAudience = firebaseConfig.AppId,
ValidateLifetime = true
};
options.Events = new JwtBearerEvents
{
OnMessageReceived = context =>
{
var path = context.Request.Path;
if (path.StartsWithSegments("/chat"))
{
var accessToken = context.Request.Query["access_token"];
if (!string.IsNullOrEmpty(accessToken))
{
context.Request.Headers.Add("Authorization", new[] { $"Bearer {accessToken}" });
}
}
return Task.CompletedTask;
}
};
});
@kyi87 thanks man saved lots of time waste
Hello, im not able to connect to the server via HttpTransportType.WebSockets. Only LongPolling is working.
The error in my Flutter App:
Flutter:
The Server is running AspNetCore .NET 6. and it seems the connection is established:
Server:
Does anyone experiencing the same Problem?
Thank you.