0

我尝试向为我提供 JWT 的身份验证服务器发出 POST 请求。但是我没有将值打包到请求中。代码行 'var content = new FormUrlEncodedContent(values);' 似乎没有效果。有人知道我可以尝试什么吗?在这种情况下,我的 responseString 表示缺少 grant-type 参数:

"{\"error\":\"invalid_request\",\"error_description\":\"缺少必需的 'grant_type' 参数。\"}"

这是我的代码:

private async void postAuthentication(LoginViewModel model)
        {
            var values = new Dictionary<string, string>
            {
               { "grant-type", "password" },
               { "username", model.Email },
               { "password", model.Password },
               { "scope", "openid" }
            };

            var content = new FormUrlEncodedContent(values); //alternative way to declare?

            var response = await client.PostAsync("http://localhost:5000/connect/token", content);

            var responseString = await response.Content.ReadAsStringAsync();
        }
4

0 回答 0