enter image description here我在ASP.NET中创建了REST API,并使用http://server/token
作为URL。如何使客户端对ASP.NET WebAPI进行身份验证?
有
content-type: application/x-www-form-urlencode
身体有grant_type
作为密码,用户名和密码会得到JSON数据与令牌头。
用于进一步的数据访问令牌可以在上面方法中使用的的工作原理与邮差
我需要实现的Android Studio或Xamarin的客户端。
因为邮递员的网址是“example.com/token”; ,然后在Header Key值pais中为内容类型(“Content-Type:application/x-www-form-urlencoded)并且在body key值对中为(grant_type:password,username:email,password:pass)响应采用json格式,如下所示{“access_token”:“token”,“token_type”:“bearer”,“expires_in”:1209599,“userName”:“[email protected]”,“.issued”:“Fri ,2016年12月9日19时19分18秒“,”.expires“:”2016年12月23日星期五19:19:18 GMT“} 同样需要在android中完成
你能更清楚地解释你的请求是如何做出来的吗?标记是否设置了标题或参数,或者可能是请求的主体?邮差的例子可以帮助你理解你的问题。 – Cheesebaron
作为邮递员的URL是“http://example.com/token”,然后在内容类型的标题密钥值pais中(“Content-Type:application/x-www-form-urlencoded)”和主体键值对作为(grant_type:密码,用户名:email,密码:pass)并且在发送响应之后以json格式如下{ “access_token”:“token”, “token_type”:“bearer”, “expires_in”:1209599 , “userName”:“[email protected]”, “。“2016年12月9日星期五19:19:18 GMT”, “.expires”:“2016年12月23日星期五19:19:18 GMT” } – dharav
我需要在android – dharav