<script src="https://www.gstatic.com/firebasejs/3.4.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "mykey",
authDomain: "myapp.firebaseapp.com",
databaseURL: "https://myapp.firebaseio.com",
storageBucket: "myapp.appspot.com",
messagingSenderId: "698532324181"
};
firebase.initializeApp(config);
</script>from firebase import firebase
from firebase_token_generator import create_token
from firebase import FirebaseAuthentication // but this is greyed out in PyCharm for some reason
#Method A
firebase = firebase.FirebaseApplication('https://myapp.firebaseio.com')
authentication = firebase.Authentication('mypwd', 'myemail', extra={'id': 123})
firebase.authentication = authentication
print authentication.extra
user = authentication.get_user()
print user.firebase_auth_token
result = firebase.get('/timeoff', None)
print result
but when running it on PyCharm I get:
AttributeError: 'FirebaseApplication' object has no attribute 'Authentication'
#Method Bauth_payload = { "uid": "uniqueId1", "auth_data": "foo", "other_auth_data": "bar" }
token = create_token("<YOUR_FIREBASE_SECRET>", auth_payload)
but I dont know how to use this and I cant find my firebase secret.
Please help!
import datetime
from firebase.firebase
import FirebaseApplication, FirebaseAuthentication
if __name__ == '__main__':
SECRET = '12345678901234567890'
DSN = 'https://firebase.localhost'
EMAIL = 'yo...@email.com'
authentication = FirebaseAuthentication(SECRET, EMAIL, True, True)
firebase = FirebaseApplication(DSN, authentication)
firebase.get('/users', None,
params = {
'print': 'pretty'
},
headers = {
'X_FANCY_HEADER': 'very fancy'
})
data = {
'name': 'Ozgur Vatansever',
'age': 26,
'created_at': datetime.datetime.now()
}
snapshot = firebase.post('/users', data)
print(snapshot['name'])
def callback_get(response):
with open('/dev/null', 'w') as f:
f.write(response)
firebase.get_async('/users', snapshot['name'], callback = callback_get)