wooldoughnut310 / micropython-firebase-auth Goto Github PK
View Code? Open in Web Editor NEWFirebase Auth implementation for Micropython
License: MIT License
Firebase Auth implementation for Micropython
License: MIT License
Hi,
I'm trying this library and fth firebase-firestore one.
I can connect to my database because I can read
But I can't write in it and I've no error message, then I can't know why
Firestore rules :
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{user} {
allow read, write: if request.auth != null;
}
}
}
My code :
import os
import network
import time
import ujson, urequests, _thread
SSID = "SSID"
password = "password"
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
wlan.connect(SSID, password)
print("Attente de la connexion WIFI", end="...")
while not wlan.isconnected():
print(".", end="")
time.sleep(1)
print()
print("Reseau WIFI", SSID , "connecté :", wlan.ifconfig()[0])
import ufirestore as firestore
from json import FirebaseJson
from firebase_auth import FirebaseAuth
from firebase_auth import AuthSession
firestore.set_project_id("firestore-db-test1")
auth = FirebaseAuth("API_KEY")
auth.sign_in("[email protected]", "AAAAAAA")
firestore.set_access_token(auth.session.access_token)
print("===== Lecture =====")
print("")
raw_doc = firestore.get("users/")
print("raw_doc : ", raw_doc)
print("")
print("===== Ecriture =====")
print("")
doc = FirebaseJson()
doc.set("Name/stringValue", "John Doe")
doc.set("Age/integerValue", 25)
response = firestore.create("users/", doc, bg=False)
print(response)
auth.sign_out()
The results :
===== Lecture =====
raw_doc : {'documents': [{'fields': {'Age': {'stringValue': '21'}, 'Name': {'stringValue': 'Jane Doe'}}, 'createTime': '2022-10-31T12:32:34.756017Z', 'name': 'projects/firestore-db-test1/databases/(default)/documents/users/FhjDBdURqcaQlpwdXlFG', 'updateTime': '2022-10-31T12:32:34.756017Z'}]}
===== Ecriture =====
Traceback (most recent call last):
File "", line 92, in
File "ufirestore.py", line 222, in create
File "ufirestore.py", line 90, in create
File "ufirestore.py", line 53, in send_request
File "urequests.py", line 104, in request
AssertionError:
I need help because I really don't know I happened
Thanks in advance
The newly changed package manager mip
can neither find any micropython-firebase related libraries, nor does the latest micropython have 'upip'.
This implies neither
import upip
upip.install('xyz-related-to-firebase')
nor
import mip
mip.install('xyz-related-to-firebase')
will work.
WORK-AROUND
Use an older version of micropython (I wish I got this idea sooner my problems would've been solved by now smh.)
WARNING
I don't know what libraries are available with the new mip
package manager other than firebase-related libraries. I suggest checking them and mentioning the version of micropython compatible with them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.