【发布时间】:2020-08-17 01:31:09
【问题描述】:
我正在尝试根据 this blog 使用 Firebase auth 对我的后端 API(目前只有本地)进行身份验证。
即使我传递(我假设)正确的令牌,我总是会收到未经授权的 401。我只是在我的控制器上使用[Authorize] 属性。
我需要更多设置,允许本地主机域,设置权限还是我做错了设置?
我的 Firebase 控制台
我的 Startup.cs
.AddJwtBearer(options =>
{
string projectId = "eisenhower-255ca";
options.Authority = "https://securetoken.google.com/" + projectId;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = "https://securetoken.google.com/" + projectId,
ValidateAudience = true,
ValidAudience = projectId,
ValidateLifetime = true,
};
});
这是我发送的 JWT 令牌
{
"name": "My Name",
"picture": "https://lh4.googleusercontent.com/-5TcxgD5tEPM/AAAAAAAAAAI/AAAAAAAAAAA/AAKWJJNudlhDY8TkE5x1HLlh7hwZFA5dew/photo.jpg",
"iss": "https://securetoken.google.com/eisenhower-255ca",
"aud": "eisenhower-255ca",
"auth_time": 1588413429,
"user_id": "3Ot95XQyenTvBmdTnGO5HcsihBs2",
"sub": "3Ot95XQyenTvBmdTnGO5HcsihBs2",
"iat": 1588413429,
"exp": 1588417029,
"email": "myEmail@gmail.com",
"email_verified": true,
"firebase": {
"identities": {
"google.com": [
"110210403554430687155"
],
"email": [
"myEmail@gmail.com"
]
},
"sign_in_provider": "google.com"
}
}
谢谢
【问题讨论】:
标签: firebase-authentication jwt asp.net-core-webapi