Beispiel #1
0
        private async Task EnsureAccessToken()
        {
            if (DateTimeOffset.Now > _tokenWrapper.Expiry.GetValueOrDefault())
            {
                await _accessTokenSemaphore.WaitAsync();

                try
                {
                    if (DateTimeOffset.Now > _tokenWrapper.Expiry.GetValueOrDefault())
                    {
                        _tokenWrapper = await _authProvider.GetAccessTokenAsync(GraphLiteConfiguration.AzureADGraphApiRoot);
                    }
                }
                finally
                {
                    _accessTokenSemaphore.Release();
                }
            }
        }