[英]Trying to Login to the Web API using the “http://localhost:61961/Token”. Receiving 400 Bad Request Error
I am very new to C#. 我是C#的新手。
I am trying to login to Web API Rest Service using the URL - http://localhost:61961/Token . 我正在尝试使用URL- http:// localhost:61961 / Token登录到Web API Rest Service。 I am getting an error grant-type=invalid.
我收到一个错误Grant-type = invalid。 I read that Microsoft has enabled a separate Web Service for Login functionality.
我读到Microsoft已为登录功能启用了单独的Web服务。 In order to call this service from my application, I gave the Content Type as
application/x-www-form-urlencoded
and grant_type=password&username=[my Username which is an email]&password=[my password]
. 为了从我的应用程序中调用此服务,我将内容类型指定为
application/x-www-form-urlencoded
并且grant_type=password&username=[my Username which is an email]&password=[my password]
。
Can we give any value to grant_type
? 我们可以给
grant_type
任何值吗?
Is it better to customize the login functionality rather than using Microsoft Login feature? 自定义登录功能比使用Microsoft登录功能更好吗?
Thanks for help. 感谢帮助。
I was able to hit the Token service when I used the correct URL- http://localhost:[port number]/Token. 当我使用正确的URL- http:// localhost:[端口号] / Token时,我能够打通Token服务。
Also I gave the parameters in the right format - grant_type=password&username=[username]&password=[password] 我也以正确的格式给出了参数-grant_type = password&username = [username]&password = [password]
I think you need to check your token functionality closely. 我认为您需要仔细检查令牌功能。 than post specific problem.
而不是发布特定问题。 Also, In grant_type you can put any values.
另外,在grant_type中,您可以放置任何值。 From code side it generate token by inbuilt method but you can create custom method for it.
从代码方面来看,它通过内置方法生成令牌,但是您可以为其创建自定义方法。 You have to do some search on google and can find how exactly token generate functionality works.
您必须在Google上进行一些搜索,然后才能找到令牌生成功能的确切工作方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.