Passport C# Client

C# Client Library

The C# client library allows you to integrate Passport with your C# application.

Source Code:

NuGet Package:

To install the Passport C# Client from NuGet run:

PM> Install-Package Inversoft.PassportClient

Here is an example of using these methods to retrieve a User by their email address via the Passport User API:

using Com.Inversoft.Passport.Client;
using Com.Inversoft.Passport.Domain;

namespace Example
{
    public class Example
    {
        private readonly string apiKey = "6b87a398-39f2-4692-927b-13188a81a9a3";

        private readonly string passportURL = "http://localhost:9011";

        private readonly PassportClient client;

        public Example(string apiKey, string passportURL)
        {
            client = new PassportClient(apiKey, passportURL);
        }

        public User GetUserByEmail(string email)
        {
            var response = client.RetrieveUserByEmail("user@example.com");
            if (response.WasSuccessful())
            {
                var user = response.successResponse.user;
                return user;
            }
            else if (response.errorResponse != null)
            {
                // Error Handling
                var errors = response.errorResponse;
                return null;
            }
            else if (response.exception != null)
            {
                // Exception Handling
                var exception = response.exception;
                return null;
            }

            return null;
        }
    }
}