/// <summary> /// Gets the share point access information. /// </summary> /// <param name="authContext">The authentication context.</param> /// <param name="result">The result.</param> public async Task <SharePointAccessInfo> GetSharePointAccessInfo(AuthenticationContext authContext, AuthenticationResult result) { SharePointAccessInfo accessInfo; try { // retrieve sharepoint tenant url for the current user accessInfo = await AcquireSharePointAuthentication(authContext, result); _refreshTokenManager.StoreAccessToken(accessInfo, HttpContext); } catch (AdalSilentTokenAcquisitionException exception) { Exception thrownException = new Exception("An error occurred while trying to obtain SharePoint access information.\n" + exception.Message); _loggingService.LogException(thrownException); throw thrownException; } try { // retrieve user-specific data from db var user = EnsureLoginSettings(accessInfo); // get library the current user is connected to var defaultLibrary = user.DefaultLibrary; // Update access info for the with connectedLibrary if (defaultLibrary == null) { return(accessInfo); } accessInfo.DefaultLibrary = defaultLibrary; accessInfo.HostWebUrl = defaultLibrary.HostWebUrl; // Double check whether the user is an admin now that we have their default library selected // from the database if (!string.IsNullOrEmpty(accessInfo.AccessToken) && !string.IsNullOrEmpty(accessInfo.UserEmail)) { // accessInfo.IsAdmin = CheckUserSiteAdmin(defaultLibrary.HostWebUrl, accessInfo.AccessToken, // accessInfo.UserEmail); accessInfo.Update(); } return(accessInfo); } catch (Exception exception) { Exception thrownException = new Exception("An exception was thrown while trying to obtain SharePoint access information.\n" + exception.Message); _loggingService.LogException(thrownException); throw thrownException; } }