Esempio n. 1
0
        public async Task <string> GetUserPhoto(string userId)
        {
            var    MSGraph   = new MSGraphApiService(new AppClient());
            string mediaType = "";
            string thumbnail = "";

            //Recupera informações sobre o perfil do usuario atraves do email
            Response responseQuery = await MSGraph.GetPhoto <ProfilePhoto>(userId);

            var response = responseQuery.HttpResponse;

            if (response.IsSuccessStatusCode)
            {
                // Read the response as a byte array
                var responseBody = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();

                // The headers will contain information on the image type returned
                mediaType = response.Content.Headers.ContentType.MediaType;

                // Encode the image string
                thumbnail = Convert.ToBase64String(responseBody);
            }

            return($"data:{mediaType};base64,{thumbnail}");
        }
Esempio n. 2
0
        public async Task <JsonResult> GetUserInfo()
        {
            var MSGraph = new MSGraphApiService(new AppClient());

            //Recupera informações sobre o perfil do usuario atraves do email
            Response responseQuery = await MSGraph.GetUser <User>(HttpContext.User.Identity.GetUserName());

            var user = responseQuery.Data;

            if (user.IsValid())
            {
                return(Json(user));
            }
            else
            {
                return(Json(new User()
                {
                    GivenName = "Erro", Response = responseQuery.HttpResponse
                }));
            }
        }
Esempio n. 3
0
 public Form1()
 {
     InitializeComponent();
     MSGraph = new MSGraphApiService(new AppClient());
 }
Esempio n. 4
0
 static void Main(string[] args)
 {
     var _graphClient = new MSGraphApiService(new AppClient());
     var usr          = _graphClient.GetUser <User>("*****@*****.**");
     var OfficeUser   = usr.Result;
 }
Esempio n. 5
0
 public AuthController()
 {
     _graphService = new MSGraphApiService(new AppClient());
 }
Esempio n. 6
0
 static void Main(string[] args)
 {
     var _graphClient = new MSGraphApiService(new AppClient());
     var usr          = _graphClient.GetUser <Microsoft.Graph.Message>();
     var OfficeUser   = usr.Result;
 }
Esempio n. 7
0
 public MSGraphUserService(string email)
 {
     _email       = email;
     _graphClient = new MSGraphApiService(AccessTokenConfig.AccessToken);
     GetUserAsync();
 }
Esempio n. 8
0
 public MSGraphUserService()
 {
     _graphClient = new MSGraphApiService(new AppClient());
 }