Example #1
0
        public async Task <string> GetAccessTokenAsync()
        {
            if (!_authenticationResult.IsAccessTokenExpired())
            {
                return(_authenticationResult.AccessToken);
            }

            var loginSuccess = await SilentLoginAsync();

            if (loginSuccess)
            {
                return(_authenticationResult.AccessToken);
            }
            else
            {
                // The token has expired and we can't obtain a new one
                // The session will be closed.
                _authenticationResult = null;
                LoggedOut?.Invoke(this, EventArgs.Empty);
                return(string.Empty);
            }
        }