CodeAuthSDK 1.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package CodeAuthSDK --version 1.1.2
                    
NuGet\Install-Package CodeAuthSDK -Version 1.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeAuthSDK" Version="1.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeAuthSDK" Version="1.1.2" />
                    
Directory.Packages.props
<PackageReference Include="CodeAuthSDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CodeAuthSDK --version 1.1.2
                    
#r "nuget: CodeAuthSDK, 1.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CodeAuthSDK@1.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CodeAuthSDK&version=1.1.2
                    
Install as a Cake Addin
#tool nuget:?package=CodeAuthSDK&version=1.1.2
                    
Install as a Cake Tool

CodeAuth .NET SDK

NuGet

Offical CodeAuth SDK. For more info, check the docs on our official website.

Installation

From within Visual Studio:

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages...
  4. Click on the Browse tab and search for "CodeAuthSDK".
  5. Click on the CodeAuthSDK package, select the appropriate version in the right-tab and click Install.

OR

Using the .NET Core command-line interface (CLI) tools]

dotnet add package CodeAuthSDK

Basic Usage

Initialize CodeAuth SDK

using CodeAuthSDK;
CodeAuth.Initialize("<your project API endpoint>",  "<your project ID>");

Signin / Email

Begins the sign in or register flow by sending the user a one time code via email.

var result = await CodeAuth.SignInEmail("<user email>");
switch (result.error)  
{  
	case "bad_json":  break;  
	case "project_not_found": break;
	case "bad_ip_address": break;
	case "rate_limit_reached": break;
	case "bad_email": break;
	case "code_request_interval_reached": break;
	case "code_hourly_limit_reached": break;
	case "email_provider_error": break;
	case "internal_error": break;
	case "connection_error": break; // sdk failed to connect to api server
}

Signin / Email Verify

Checks if the one time code matches in order to create a session token.

var result = await CodeAuth.SignInEmailVerify("<user email>", "<one time code>");
switch (result.error)
{
	case "bad_json": break;
	case "project_not_found": break;
	case "bad_ip_address": break;
	case "rate_limit_reached": break;
	case "bad_email": break;
	case "bad_code": break;
	case "internal_error": break;
	case "connection_error": break; // sdk failed to connect to api server
}
Console.WriteLine(result.session_token);
Console.WriteLine(result.email);
Console.WriteLine(result.expiration);
Console.WriteLine(result.refresh_left);

Signin / Social

Begins the sign in or register flow by allowing users to sign in through a social OAuth2 link.

var result = await CodeAuth.SignInSocial("<social type>");
switch (result.error)
{
	case "bad_json": break;
	case "project_not_found": break;
	case "bad_ip_address": break;
	case "rate_limit_reached": break;
	case "bad_social_type": break;
	case "internal_error": break;
	case "connection_error": break; // sdk failed to connect to api server
}
Console.WriteLine(result.signin_url);

Signin / Social Verify

This is the next step after the user signs in with their social account. This request checks the authorization code given by the social media company in order to create a session token.

var result = await CodeAuth.SignInSocialVerify("<social type>", "<authorization code>");
switch (result.error)
{
	case "bad_json": break;
	case "project_not_found": break;
	case "bad_ip_address": break;
	case "rate_limit_reached": break;
	case "bad_social_type": break;
	case "bad_authorization_code": break;
	case "internal_error": break;
	case "connection_error": break; // sdk failed to connect to api server
}
Console.WriteLine(result.session_token);
Console.WriteLine(result.email);
Console.WriteLine(result.expiration);
Console.WriteLine(result.refresh_left);

Session / Info

Gets the information associated with a session token.

var result = await CodeAuth.SessionInfo("<session_token>");
switch (result.error)
{
	case "bad_json": break;
	case "project_not_found": break;
	case "bad_ip_address": break;
	case "rate_limit_reached": break;
	case "bad_session_token": break;
	case "internal_error": break;
	case "connection_error": break; // sdk failed to connect to api server
}
Console.WriteLine(result.email);
Console.WriteLine(result.expiration);
Console.WriteLine(result.refresh_left);

Session / Refresh

Create a new session token using existing session token.

var result = await CodeAuth.SessionRefresh("<session_token>");
switch (result.error)
{
	case "bad_json": break;
	case "project_not_found": break;
	case "bad_ip_address": break;
	case "rate_limit_reached": break;
	case "bad_session_token": break;
	case "out_of_refresh": break;
	case "internal_error": break;
	case "connection_error": break; // sdk failed to connect to api server
}
Console.WriteLine(result.session_token);
Console.WriteLine(result.email);
Console.WriteLine(result.expiration);
Console.WriteLine(result.refresh_left);

Session / Invalidate

Invalidate a session token. By doing so, the session token can no longer be used for any api call.

var result = await CodeAuth.SessionInvalidate("<session_token>", "<invalidate_type>");
switch (result.error)
{
	case "bad_json": break;
	case "project_not_found": break;
	case "bad_ip_address": break;
	case "rate_limit_reached": break;
	case "bad_session_token": break;
	case "bad_invalidate_type": break;
	case "internal_error": break;
	case "connection_error": break; // sdk failed to connect to api server 
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.