這是我在文章中看到的唯一的地方,invalid_grant
返回:
using (AuthRepository _repo = new AuthRepository())
{
IdentityUser user = await _repo.FindUser(context.UserName, context.Password);
if (user == null)
{
context.SetError("invalid_grant", "The user name or password is incorrect.");
return;
}
}
你是不是您的非本地服務器上的用戶名/密碼?
如果你的本地和非本地服務器不共享相同的DB:
- 你可能會使用無效的刷新令牌,或者它已過期或撤銷
- 使用可能不匹配的客戶端證書刷新令牌的客戶端發送到
它也可能是重定向URI不同於本地服務器與非本地服務器。
invalid_grant
The provided authorization grant (e.g., authorization
code, resource owner credentials) or refresh token is
invalid, expired, revoked, does not match the redirection
URI used in the authorization request, or was issued to
another client.
https://tools.ietf.org/html/rfc6749#section-5.2
我中有你顯示相同的invalid_grant代碼,但是這是在用於初始登錄的GrantOwnerResourceCredentials方法。至於規範中的invalid_grant原因,我沒有看到其中的哪一個適用。像過期和/或重定向URI(因爲這不是第三方身份驗證提供程序實現而未指定)的刷新標記參數不會更改,並且它絕對不會發布給其他客戶端,也不會被撤銷。 – HisDivineShadow
@HisDivineShadow讓您的本地和非本地服務器共享相同的數據庫?此外,任何時間偏差的機會? – neverendingqs
不,本地和dev實例使用自己的DB(在不同的DB服務器上)。訪問令牌和刷新令牌在同一應用內的同一臺服務器上生成時,會出現什麼樣的時間偏差? – HisDivineShadow