Skip to content

This dotnet SDK allows for verification of server-side authentication for applications using Passage

License

Notifications You must be signed in to change notification settings

zskovacs/passage-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Passage logo

GitHub Workflow Status GitHub Downloads NuGet current

Passage.NET

This dotnet SDK allows for verification of server-side authentication for applications using Passage

πŸ’Ύ Installation

Install this package using nuget.

dotnet add pacakge Passage.NET

πŸ’‰ Dependency injection

If you want to integrate with HttpClientFactory and Microsoft.Extensions.DependencyInjection

dotnet add pacakge Passage.Net.Extensions.DependencyInjection

Usage:

//...
builder.Services.AddPassage(options =>
{
    options.AppId = "YOUR_APP_ID";
    options.ApiKey = "YOUR_API_KEY";
});
//...
var app = builder.Build();
//...
app.MapGet("/getapp", async (IPassage passage) =>
{
    var appinfo = await passage.App.Get();
    return appinfo;
})

πŸ“’ Usage

Validate JWT

You need to provide Passage with your App ID in order to verify the JWTs.

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID"
}

var passage = new Passage(config);

var subject = await passage.Session.ValidateToken("JWT_TO_VALIDATE");

Logout

You can revoke refresh token from the given user

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID"
}

var passage = new Passage(config);

var subject = await passage.Session.RevokeRefreshToken("USER_ID");

Retrieve App Info

To retrieve information about an app, you should use the passage.GetApp() function.

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID",
    ApiKey = "YOUR_API_KEY"
}

var passage = new Passage(config);

var passageApp = await passage.App.Get();

Retrieve User Information By Identifier

To retrieve information about a user, you should use the passage.GetUserByIdentifier("your@email.cc") function.

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID",
    ApiKey = "YOUR_API_KEY"
}

var passage = new Passage(config);

var passageUser = await passage.User.GetByIdentifier("user@email.cc");

Retrieve User Information By User Id

To retrieve information about a user, you should use the passage.GetUser("USER_ID") function.

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID",
    ApiKey = "YOUR_API_KEY"
}

var passage = new Passage(config);

var passageUser = await passage.User.Get("USER_ID");

Create a User

You can also create a Passage user by providing an email or phone (phone number must be a valid E164 phone number).

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID",
    ApiKey = "YOUR_API_KEY"
}

var passage = new Passage(config);

var createRequest = new CreateUserRequest()
{
    Email = "user@email.cc",
    //note that user_metadata is an optional field and is defined in your Passage App settings (Registration Fields).
    User_metadata = new
    {
        example = 123
    }
};
    
var passageUser = await passage.User.Create(createRequest);

Update a User

You can update a user attributes

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID",
    ApiKey = "YOUR_API_KEY"
}

var passage = new Passage(config);

var updateRequest = new UpdateUserRequest()
{
    Email = "user@email.cc",
    //note that user_metadata is an optional field and is defined in your Passage App settings (Registration Fields).
    User_metadata = new
    {
        example = 1234
    }
};

var passageUser = await passage.User.Update("USER_ID",updateRequest);

Delete a User

To delete a Passage user, you will need to provide the userID, and corresponding app credentials.

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID",
    ApiKey = "YOUR_API_KEY"
}

var passage = new Passage(config);

await passage.User.Delete("USER_ID");

Activate a User

You can activate a user manually

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID",
    ApiKey = "YOUR_API_KEY"
}

var passage = new Passage(config);

var passageUser= await passage.User.Activate("USER_ID");

Deactivate a User

You can deactivate a user manually

var config = new PassageConfig()
{
    AppId = "YOUR_APP_ID",
    ApiKey = "YOUR_API_KEY"
}

var passage = new Passage(config);

var passageUser= await passage.User.Deactivate("USER_ID");

About

This dotnet SDK allows for verification of server-side authentication for applications using Passage

Resources

License

Stars

Watchers

Forks

Languages