简体   繁体   中英

Parsing token in HTTP Response body using C#

I'm sending an HTTP POST request to google Client login and I'm getting this in respons:

SID=DQAAAGgA...7Zg8CTN
LSID=DQAAAGsA...lk8BBbG
Auth=DQAAAGgA...dk3fA5N

I used the below code to read the response:

Trace.WriteLine(new StreamReader(response.GetResponseStream()).ReadToEnd());

Now in this response i want to use only the value of Auth token. Can any one please help me on how to extract only that value from the response. Thanx!

只是一个简单的答案,您需要编写的内容可能类似于以下代码:

String.Split("\n").Where(l=>l.Contains("=")).Select(l=l.Split("=")).Where(li=>li.Length==2).Where(li=>li[0].ToLower()=="auth").Select(li=>li[1]).SingleOrDefault();

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