public async Task<UserModel> GetMe()
 {
     var graphServiceClient = await GetGraphServiceAsync();
     var me = await graphServiceClient.Me.Request().GetAsync();
     UserModel myModel = new UserModel()
     {
         displayName = me.DisplayName,
         givenName = me.GivenName,
         mail = me.Mail,
         mobilePhone = me.MobilePhone
     };
     return myModel;
 }
Ejemplo n.º 2
0
 public async Task<UserModel> GetMe()
 {
     UserModel me = null;
     string restURL = string.Format("{0}/me", GraphResourceUrl);
     string responseString = await GetJsonAsync(restURL);
     if (responseString != null)
     {
         var jsonresult = JObject.Parse(responseString);
         me = new UserModel
         {
             displayName = jsonresult["displayName"].IsNullOrEmpty() ? string.Empty : jsonresult["displayName"].ToString(),
             givenName = jsonresult["givenName"].IsNullOrEmpty() ? string.Empty : jsonresult["givenName"].ToString(),
             mail = jsonresult["mail"].IsNullOrEmpty() ? string.Empty : jsonresult["mail"].ToString(),
             mobilePhone = jsonresult["mobilePhone"].IsNullOrEmpty() ? string.Empty : jsonresult["mobilePhone"].ToString(),
         };
     }
     return me;
 }