Sequencing.WeatherApp.Controllers.OAuth.AuthWorker.GetUserInfo C# (CSharp) Method

GetUserInfo() public method

Returns user name for given token
public GetUserInfo ( string token ) : DrupalOAuthInfo
token string OAuth auth token
return DrupalOAuthInfo
        public DrupalOAuthInfo GetUserInfo(string token)
        {
            try
            {
                var _uri = new Uri(oAuthUrl);
                var _leftPart = _uri.GetLeftPart(UriPartial.Authority);
                var _rq =
                    (HttpWebRequest)
                        WebRequest.Create(_leftPart + "?q=js/custom_oauth2_server/custom-token-info" + "/" + token);
                _rq.Method = "GET";
                WebResponse _webResponse = _rq.GetResponse();
                using (Stream _s = _webResponse.GetResponseStream())
                using (var _sr = new StreamReader(_s))
                {
                    string _readToEnd = _sr.ReadToEnd();

                    var _drupalOAuthInfo = JsonConvert.DeserializeObject<DrupalOAuthInfo>(_readToEnd);
                    return _drupalOAuthInfo;
                }
            }
            catch (Exception e)
            {
                throw new DaoLayer.ApplicationException(string.Format("Invalid access token {0}. {1}", token, e.Message));
            }
        }