Exemplo n.º 1
0
        public static Uri SignOut(string postLogoutRedirect)
        {
            if (_discoveryContext == null)
            {
                _discoveryContext = new Microsoft.Office365.OAuth.DiscoveryContext();
            }

            _discoveryContext.ClearCache();

            return(_discoveryContext.GetLogoutUri <SessionCache>(postLogoutRedirect));
        }
Exemplo n.º 2
0
        public static async Task <SharePointClient> EnsureClientCreated()
        {
            if (_discoveryContext == null)
            {
                _discoveryContext = await Microsoft.Office365.OAuth.DiscoveryContext.CreateAsync();
            }

            var dcr = await _discoveryContext.DiscoverResourceAsync(ServiceResourceId);

            _lastLoggedInUser = dcr.UserId;

            return(new SharePointClient(ServiceEndpointUri, async() =>
            {
                return (await _discoveryContext.AuthenticationContext.AcquireTokenByRefreshTokenAsync(new SessionCache().Read("RefreshToken"), new Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential(_discoveryContext.AppIdentity.ClientId, _discoveryContext.AppIdentity.ClientSecret), ServiceResourceId)).AccessToken;
            }));
        }