问题描述
对不起,我的语言不好。我想知道在登录xamarin.forms后如何获取令牌。我在邮递员中输入我的电子邮件和密码,它会生成在底部可见的令牌
解决方法
您可以使用HttpClient来Consume a RESTful Web Service并从响应中获取令牌:
public async void test() {
var client = new HttpClient();
string jsonData = @"{""username"" : ""myusername"",""password"" : ""mypassword""}";
var content = new StringContent(jsonData,Encoding.UTF8,"application/json");
HttpResponseMessage response = await client.PostAsync("your request url",content);
// this result string should be something like: "{"token":"rgh2ghgdsfds"}"
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}