GitHub.Api.SimpleApiClient.IsAuthenticated C# (CSharp) Method

IsAuthenticated() public method

public IsAuthenticated ( ) : bool
return bool
        public bool IsAuthenticated()
        {
            // this doesn't account for auth revoke on the server but its much faster 
            // than doing the API hit.
            var authType = client.Connection.Credentials?.AuthenticationType ?? AuthenticationType.Anonymous;
            return authType != AuthenticationType.Anonymous;
        }

Usage Example

        public void ReturnsFalseWhenAuthenicationTypeIsAnonymous()
        {
            var connection = Substitute.For<IConnection>();
            connection.Credentials=Credentials.Anonymous;

            var gitHubClient = Substitute.For<IGitHubClient>();
            gitHubClient.Connection.Returns(connection);

            var client = new SimpleApiClient(
                "https://github.com/github/visualstudio",
                gitHubClient,
                null,
                null);

            var result = client.IsAuthenticated();
            Assert.False(result);
        }
All Usage Examples Of GitHub.Api.SimpleApiClient::IsAuthenticated