【发布时间】:2017-04-25 05:57:51
【问题描述】:
enter image description here我在 ASP.NET 中创建了 REST API,并使用http://server/token 作为 URL。
标题有
content-type: application/x-www-form-urlencode
body有grant_type作为密码,用户名和密码会得到带有token的json数据。
为了进一步的数据访问令牌,可以使用上述方法与邮递员一起使用
我需要在 Android Studio 或 Xamarin 中实现一个客户端。
因为邮递员中的网址是“example.com/token”; ,然后在内容类型的标题键值中为 ("Content-Type:application/x-www-form-urlencoded) 和在正文键值对中为 (grant_type:password, username:email,password:pass) 和发送后响应采用 json 格式如下 { "access_token": "token", "token_type": "bearer", "expires_in": 1209599, "userName": "mail@gmail.com", ".issued": "Fri , 2016 年 12 月 9 日 19:19:18 GMT”,“.expires”:“周五,2016 年 12 月 23 日 19:19:18 GMT”} 这同样需要在 android 中完成
【问题讨论】:
-
您能否更清楚地解释您的请求是如何提出的?令牌是否设置了标头或参数,或者可能是请求的主体?邮递员的一个例子将有助于理解您的问题。
-
因为邮递员中的 url 是 "example.com/token" ,然后在 Header Key value pais for content type as ("Content-Type:application/x-www-form-urlencoded) 和 body key value配对为 (grant_type:password, username:email,password:pass),发送后响应为 json 格式,如下 { "access_token": "token", "token_type": "bearer", "expires_in": 1209599, "用户名”:“mail@gmail.com”,“.issued”:“格林威治标准时间 2016 年 12 月 9 日星期五 19:19:18”,“.expires”:“格林威治标准时间 2016 年 12 月 23 日星期五 19:19:18”}
-
我需要在 android 中做同样的事情
-
请用您在 cmets 中写的内容更新问题正文,这会让其他人更容易阅读
-
我想你可以试试我的答案stackoverflow.com/questions/32696960/…
标签: android android-studio asp.net-web-api http-post restful-authentication