Cotter Login SDK for Python CLI
Cotter's Python SDK for Passwordless Authentication using Email/Phone Number for your CLI and scripts. To read more about Cotter, get started with our 📚 integration guides and example projects.
Find the most updated documentation on our site or our Github:
Installation
pip install cotter
Find the latest versions here https://pypi.org/project/cotter/
Usage
Get your API_KEY_ID from Cotter's Dashboard.
Step 1: Copy cotter_login_success.html from the example folder.
You can make your own Success page. After the user successfully logged-in, the website will redirect to http://localhost:port and you should show a "Success message" and tell the user to go back to your terminal. Feel free to copy our example page and modify it.
Put the success page with name cotter_login_success.html at the same directory as where you put the code below
Step 2: Call Cotter's login function
import cotter
api_key = "YOUR API KEY ID"
port = 8080 # Open a port to receive code from the website after successful authentication
response = cotter.login_with_email_link(api_key, port)
print(response)
Available methods:
Using Email
# Use Magic Link
response = login_with_email_link(api_key, port)
# Use OTP
response = login_with_email_otp(api_key, port)
Using Phone Number
# Use Magic Link
response = login_with_phone_link(api_key, port)
# Use OTP
response = login_with_phone_otp(api_key, port)
Storing the tokens
Store the tokens to a file:
from cotter import tokenhandler
tokenhandler.store_token_to_file(response["oauth_token"], "cottertoken.json")
Get the tokens to a file (automatically refresh if needed):
from cotter import tokenhandler
oauth_token = tokenhandler.get_token_from_file("cottertoken.json", api_key)
Refreshing tokens (if not using the functions above)
# This will only refresh if needed
from cotter import tokenhandler
oauth_token = tokenhandler.refresh_token(oauth_token, api_key)
Validating tokens
from cotter import validate
access_token_decoded = validate.validate_access_token(response["oauth_token"]["access_token"], api_key)
id_token_decoded = validate.validate_id_token(response["oauth_token"]["id_token"], api_key)
Troubleshooting
Allowed Origin Error
If you get an error like this:
{
"msg": "The redirect URL http://localhost:1234 or the parent origin :// is not in the list of allowed URLs. Please contact the site owner.",
"type": ""
}
You may have set up a list of Allowed URLs in the dashboard. Make sure you add these 2 urls:
http://localhost:<PORT>based on the port you used above://(this is a bug, join our Slack channel to be updated)
Metadata
Release files for cotter 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cotter-0.0.7.tar.gz | 6.1 kB | Without provenance | Details for cotter-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cotter-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for cotter-0.0.7-py3-none-any.whl |
Total release size: 13.0 kB
Release files / cotter-0.0.7.tar.gz
| Download URL | cotter-0.0.7.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5fa3d8b500f96ac1a8c5ea734be20e839ca29e461dd28a343dae90205bc5d376
|
|
BLAKE2b-256 checksum How to use checksums |
74ae226a8961964c86b1a2045853d11ffe4873440fe1bd33aa885e25dfdd8dd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / cotter-0.0.7-py3-none-any.whl
| Download URL | cotter-0.0.7-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
175c26a0f1ace3480e3a31329ec2b569d126d5f72500c7fe496e589cd5e4c2df
|
|
BLAKE2b-256 checksum How to use checksums |
57ba9e97afd754947a6fa86b79f1c4d5569409f41129b212a0068fd530225577
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Security for cotter 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.