Esempio n. 1
0
 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;
     }
 }
Esempio n. 2
0
 public ActionResult LogOff()
 {
     AuthenticationManager.SignOut();
     return(Helper.JsonSucess());
 }