private string GetEmail(string accessToken) { try { var emailRequest = "https://openidconnect.googleapis.com/v1/userinfo?alt=json&access_token=" + accessToken; // Create a request for the URL. var request = WebRequest.Create(emailRequest); // Get the response. var response = (HttpWebResponse)request.GetResponse(); // Get the stream containing content returned by the server. var dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. var reader = new StreamReader(dataStream); // Read the content. var jsonString = reader.ReadToEnd(); // Cleanup the streams and the response. reader.Close(); dataStream.Close(); response.Close(); var jsonObj = JObject.Parse(jsonString); return((string)jsonObj["email"]); } catch (Exception ex) { Helper.ErrorLog("GetEmail: access_token=" + accessToken, ex); throw ex; } }
public ActionResult LogOff() { AuthenticationManager.SignOut(); return(Helper.JsonSucess()); }