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>", "<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_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)

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.

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.2.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codeauth_sdk-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 95e8aa0f567f0eb2f656dd2217b24b7f2aca14b56a856ec835ef95ad54c4b30f
MD5 1ab125ff869946d6be0311ad9d7c9756
BLAKE2b-256 9c6c4561d349dd5b314cd10938df842c1df09ab40df69f5d3362a330fb648df6

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