简体   繁体   中英

Trying to Login to the Web API using the “http://localhost:61961/Token”. Receiving 400 Bad Request Error

I am very new to C#.

I am trying to login to Web API Rest Service using the URL - http://localhost:61961/Token . I am getting an error grant-type=invalid. I read that Microsoft has enabled a separate Web Service for Login functionality. 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] .

Can we give any value to grant_type ?

Is it better to customize the login functionality rather than using Microsoft Login feature?

Thanks for help.

I was able to hit the Token service when I used the correct URL- http://localhost:[port number]/Token.
Also I gave the parameters in the right format - 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM