Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Official Dotnet SDK for the Stytch API

License

stytchauth/stytch-dotnet

Repository files navigation

Stytch dotnet Library

The Stytch .NET library makes it easy to use the Stytch user infrastructure API in .NET applications.

Install

Using .NET CLI:

dotnet add package Stytch.net

Usage

You can find your API credentials in the Stytch Dashboard.

This client library supports all of Stytch's live products:

B2C

B2B

Example B2C usage

Create an API client:

using Stytch.net.Clients;

var client = new Stytch.net.Clients.ConsumerClient(new ClientConfig
{
    ProjectId = "project-live-c60c0abe-c25a-4472-a9ed-320c6667d317",
    ProjectSecret = "secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I="
});

Send a magic link by email:

client.OTPs.Email.LoginOrCreate(new OTPsEmailLoginOrCreateRequest(email: "[email protected]"){
    LoginMagicLinkUrl = "https://example.com/authenticate",
    SignupMagicLinkUrl = "https://example.com/authenticate"
});

Authenticate the token from the magic link:

client.MagicLinks.Authenticate(new AuthenticateRequest(token: "DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94="));

Example B2B usage

Create an API client:

using Stytch.net.Clients;

var client = new Stytch.net.Clients.B2BClient(new ClientConfig
{
    ProjectId = "project-live-c60c0abe-c25a-4472-a9ed-320c6667d317",
    ProjectSecret = "secret-live-80JASucyk7z_G8Z-7dVwZVGXL5NT_qGAQ2I="
});

Create an organization

client.Organizations.Create(new B2BOrganizationsCreateRequest(organizationName: "Acme Co"){
    OrganizationSlug = "acme-co",
    EmailAllowedDomains = ["acme.co"],
    EmailJITProvisioning = "RESTRICTED"
});

Log the first user into the organization

client.MagicLinks.Email.LoginOrSignup(new B2BMagicLinksEmailLoginOrSignupRequest(){
    OrganizationId = "organization-id-from-create-response-...",
    EmailAddress = "[email protected]",
}));

JSON dependencies

This SDK has a dependency on Newtonsoft.Json. You may see some issues with JSON deserialization if your project is using System.Text.Json.

Support

If you've found a bug, open an issue!

If you have questions or want help troubleshooting, join us in Slack or email [email protected].

If you've found a security vulnerability, please follow our responsible disclosure instructions.

Development

See DEVELOPMENT.md

Code of Conduct

Everyone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

Official Dotnet SDK for the Stytch API

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 8

Languages