micropython-firebase-auth
Firebase implementation based on REST API, based on micropython-firebase-realtime-database from ckoever.
Installation
You can use uPip to install library from PyPi
import upip
upip.install("micropython-firebase-auth")
or you can just upload firebase_auth/firebase_auth.py to your microcontroller:
python pyboard.py -d PORT -f cp firebase_auth.py :
Commands that are implemented
- sign_in
- sign_out
- sign_up
Required modules
ujson, urequests, time, sys
Connect to Wifi
import time
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
wlan.connect("ssid", "pass")
print("Waiting for Wi-Fi connection", end="...")
while not wlan.isconnected():
print(".", end="")
time.sleep(1)
print()
Create a FirebaseAuth instance
from firebase_auth import FirebaseAuth
auth = FirebaseAuth("API_KEY")
The API key is required, read about it here
or you can find it at Project Settings > General in your project's console
Functions
sign_in
auth.sign_in(email, password)
Authenticate a user with email and password
sign_up
auth.sign_up(email=None, password=None)
Registers an account with the given email and password
-
leave
emailandpasswordempty to sign in anonymouslyauth.sign_up(None, None) # Sign in as guest
Example:
auth.sign_up("email", "password")
print("Hello, " + auth.user.display_name)
sign_out
auth.sign_out()
Clears authentication session and stored user data
Attributes
user
auth.user: dict()
Returns the user data for the currently authenticated user
session
auth.session: AuthSession
The AuthSession object used to handle requests to the backend
AuthSession
request
session.request(method, endpoint, data=None, method=None, **kwargs)
Make a request to an auth endpoint requiring an idToken (the accessToken) (if method is not None, else an endpoint that returns tokens)
access_token
session.access_token
Gets the access token for use within other Firebase services such as RTDB, Firestore, etc.
AuthSession.load_credentials
AuthSession.load_credentials()
Reads a stored version of session credentials from a credentials.json file
AuthSession.save_credentials
AuthSession.save_credentials(creds)
Stores a session credentials object into credentials.json file
Example:
# Storing data on system before going to sleep for 10s
import machine
creds = auth.session.credentials
AuthSession.save_credentials(creds)
machine.deepsleep(10000)
Metadata
Release files for micropython-firebase-auth 1.0.6
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 | |
|---|---|---|---|---|
| micropython-firebase-auth-1.0.6.tar.gz | 5.1 kB | Without provenance | Details |
Release files / micropython-firebase-auth-1.0.6.tar.gz
| Download URL | micropython-firebase-auth-1.0.6.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3f2787e38d193580e759f31044aa1dfc53a372ef71a38ce31ec3993839f6aa0
|
|
BLAKE2b-256 checksum How to use checksums |
3f4d101b6d6b0713c314bd02a721e59cd164bf45dec2cb94ff0ea70ede7821bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
|
Security for micropython-firebase-auth 1.0.6
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.