简体   繁体   English

尝试使用“ http:// localhost:61961 / Token”登录到Web API。 收到400错误的请求错误

[英]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.

相关问题 我正在尝试使用 c# 从 Twitter api 获取请求令牌,但收到 400 个错误的请求错误 - I am trying to get request token from Twitter api using c#, but getting 400 bad request error ASP.NET Web API HTTP 400错误请求 - ASP.NET Web API HTTP 400 Bad Request Web api:400 错误请求 - Web api: 400 bad request 难以接收来自 API 的 HTTP 响应 — 错误请求错误 - Difficulty receiving an HTTP Response from API — Bad Request Error .NET中使用OpenTSDB HTTP API:400错误请求 - using OpenTSDB HTTP api in .NET : 400 Bad Request HTTP 400错误请求错误C# - HTTP 400 Bad Request Error C# 字符编码导致我的 ASP Web API 请求失败并显示 HTTP 400:错误请求 - Character Encoding causes my ASP Web API request to fail with HTTP 400: Bad Request Google Calendar API-错误请求(400)试图交换访问令牌的代码 - Google Calendar API - Bad Request (400) Trying To Swap Code For Access Token 调用Web服务“ 400错误的请求”错误 - Calling web service “400 Bad Request” error Http Web请求远程服务器返回错误:(400)错误的请求。 Twitter时间轴 - Http web request The remote server returned an error: (400) Bad Request. twitter timeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM