Example #1
0
        protected async Task <(User, string)> GetGraphUserData()
        {
            User   graphUser = CurrentSession.GetFromJSONTo <User>(Constants.UserKey);
            string imageData;

            if (graphUser == null)
            {
                GraphServiceClient graphClient = GetGraphServiceClient(new[] { Constants.ScopeUserRead });
                (graphUser, imageData) = await graphClient.GetCurrentUserFromGraph();

                CurrentSession.AddToJSONFrom <User>(Constants.UserKey, graphUser);

                if (imageData != null)
                {
                    CurrentSession.SetString(Constants.PictureKey, imageData);
                }
            }
            else
            {
                imageData = CurrentSession.GetString(Constants.PictureKey);
            }

            return(graphUser, imageData);
        }