Skip to main content

Official Python SDK for CodeAuth

Project description

CodeAuth Python SDK

Version

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

Installation

This package is available on PyPI:

pip install --upgrade codeauth-sdk

Basic Usage

Initialize CodeAuth SDK

from codeauth_sdk import (CodeAuth)
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.

result = CodeAuth.SignInEmail("<user email>")
match result.error
{
	case "bad_json": print("bad_json")
	case "project_not_found": print("project_not_found")
	case "bad_ip_address": print("bad_ip_address")
	case "rate_limit_reached": print("rate_limit_reached")
	case "bad_email": print("bad_email")
	case "code_request_interval_reached": print("code_request_interval_reached")
	case "code_hourly_limit_reached": print("code_hourly_limit_reached")
	case "email_provider_error": print("email_provider_error")
	case "internal_error": print("internal_error")
	case "connection_error": print("connection_error") #sdk failed to connect to api server
}

Signin / Email Verify

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

result = CodeAuth.SignInEmailVerify("<user email>", "<one time code>")
match result.error
{
	case "bad_json": print("bad_json")
	case "project_not_found": print("project_not_found")
	case "bad_ip_address": print("bad_ip_address")
	case "rate_limit_reached": print("rate_limit_reached")
	case "bad_email": print("bad_email")
	case "bad_code": print("bad_code")
	case "internal_error": print("internal_error")
	case "connection_error": print("connection_error") #sdk failed to connect to api server
}
print(result.session_token)
print(result.email)
print(result.expiration)
print(result.refresh_left)

Signin / Social

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

result = CodeAuth.SignInSocial("<social_type>")
match result.error
{
	case "bad_json": print("bad_json")
	case "project_not_found": print("project_not_found")
	case "bad_ip_address": print("bad_ip_address")
	case "rate_limit_reached": print("rate_limit_reached")
	case "bad_social_type": print("bad_social_type")
	case "internal_error": print("internal_error")
	case "connection_error": print("connection_error") #sdk failed to connect to api server
}
print(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.

result = CodeAuth.SignInSocialVerify("<social type>", "<authorization code>")
match result.error
{
	case "bad_json": print("bad_json")
	case "project_not_found": print("project_not_found")
	case "bad_ip_address": print("bad_ip_address")
	case "rate_limit_reached": print("rate_limit_reached")
	case "bad_social_type": print("bad_social_type")
	case "bad_authorization_code": print("bad_authorization_code")
	case "internal_error": print("internal_error")
	case "connection_error": print("connection_error") #sdk failed to connect to api server
}
print(result.session_token)
print(result.email)
print(result.expiration)
print(result.refresh_left)

Session / Info

Gets the information associated with a session token.

result = CodeAuth.SessionInfo("<session_token>")
match result.error
{
	case "bad_json": print("bad_json")
	case "project_not_found": print("project_not_found")
	case "bad_ip_address": print("bad_ip_address")
	case "rate_limit_reached": print("rate_limit_reached")
	case "bad_session_token": print("bad_session_token")
	case "internal_error": print("internal_error")
	case "connection_error": print("connection_error") #sdk failed to connect to api server
}
print(result.email)
print(result.expiration)
print(result.refresh_left)

Session / Refresh

Create a new session token using existing session token.

result = CodeAuth.SessionRefresh("<session_token>")
match result.error
{
	case "bad_json": print("bad_json")
	case "project_not_found": print("project_not_found")
	case "bad_ip_address": print("bad_ip_address")
	case "rate_limit_reached": print("rate_limit_reached")
	case "bad_session_token": print("bad_session_token")
	case "out_of_refresh": print("out_of_refresh")
	case "internal_error": print("internal_error")
	case "connection_error": print("connection_error") #sdk failed to connect to api server
}
print(result.session_token)
print(result.email)
print(result.expiration)
print(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 = CodeAuth.SessionInvalidate("<session_token>", "<invalidate_type>")
match result.error
{
	case "bad_json": print("bad_json")
	case "project_not_found": print("project_not_found")
	case "bad_ip_address": print("bad_ip_address")
	case "rate_limit_reached": print("rate_limit_reached")
	case "bad_session_token": print("bad_session_token")
	case "bad_invalidate_type": print("bad_invalidate_type")
	case "internal_error": print("internal_error")
	case "connection_error": print("connection_error") #sdk failed to connect to api server 
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codeauth_sdk-1.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file codeauth_sdk-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: codeauth_sdk-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for codeauth_sdk-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98b0ec341c6ad7f7ab6d58c5142bb7aba614d5766afc95e64232cf21444290fa
MD5 5e2e2ac7053e01990dd6c1bba1dde26a
BLAKE2b-256 de6e4c85b19ff388c62b9516a86e20d74311fbe8eee8de4553510466f2c5646b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page