Metadata-Version: 2.4
Name: codeauth_sdk
Version: 1.1.0
Summary: Official Python SDK for CodeAuth
Home-page: https://codeauth.com
Author: CodeAuth
License: APACHE 2.0
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: summary

# CodeAuth Python SDK
[![Version](https://img.shields.io/pypi/v/codeauth-sdk)](https://www.pypi.org/project/codeauth-sdk/)

Offical CodeAuth SDK. For more info, check the docs on our [official website](https://docs.codeauth.com).

## Installation
This package is available on PyPI:

```
pip install --upgrade codeauth-sdk
```

## Basic Usage

### Initialize CodeAuth SDK
```python
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.
```javascript
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```javascript
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 
}
```

