This dotnet SDK allows for verification of server-side authentication for applications using Passage
Install this package using nuget.
dotnet add pacakge Passage.NET
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;
})
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");
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");
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();
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");
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");
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);
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);
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");
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");
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");