Exemplo n.º 1
0
def login():
    config = {
        "apiKey": "AIzaSyDr3GgNZ7hJhhXb9Grys6xrTRRFsWJlQGA",
        "authDomain": "mp3wizard-466b5.firebaseapp.com",
        "databaseURL": "https://mp3wizard-466b5.firebaseio.com",
        "storageBucket": "mp3wizard-466b5.appspot.com"
    }

    firebase = Firebase(config)
    auth = firebase.auth()

    w.emailEntry.configure(state="disabled")
    w.passwordEntry.configure(state="disabled")
    try:
        user = auth.sign_in_with_email_and_password(w.emailEntry.get(),
                                                    w.passwordEntry.get())
        validUser = True
    except HTTPError:
        print(str(HTTPError.__text_signature__))
        w.emailEntry.configure(state="normal")
        w.passwordEntry.configure(state="normal")
        w.errorLabel.configure(text="Error when attempting to login")
        w.errorLabel.configure(foreground='#FF0000')
        sys.stdout.flush()
    if validUser:
        print(user)
        print(type(user))
        destroy_window()
        uploadBookDash_support.start(user)
Exemplo n.º 2
0
def _init_database():
    global user
    global db
    global firebase

    print("Initializing database...")

    project_id = "fir-test-for-atb-default-rtdb"
    config = {
        "apiKey": token_loader.FIREBASE,
        "authDomain": f"{project_id}.firebaseapp.com",
        "databaseURL": f"https://{project_id}.firebaseio.com",
        "storageBucket": f"pro{project_id}jectId.appspot.com"
    }

    firebase = Firebase(config)

    # Get a reference to the auth service
    auth = firebase.auth()

    # Log the user in
    load_dotenv()
    username = os.getenv('FIREBASE_USERNAME')
    password = os.getenv('FIREBASE_PASSWORD')
    user = auth.sign_in_with_email_and_password(username, password)
    set_next_token_refresh_time()

    # Get a reference to the database service
    db = firebase.database()
Exemplo n.º 3
0
def fazer_login(email: str, senha: str) -> list:
    '''Tenta faze login usando o firebase'''
    firebase = Firebase(config)
    auth = firebase.auth()
    try:
        user = auth.sign_in_with_email_and_password(email, senha)
        return [user, 200]
    except:
        return [404]
 def __init__(self):
     with open('firebase_config.json', 'r') as file:
         config = json.loads(file.read())
     firebase = Firebase(config)
     auth = firebase.auth()
     user = auth.sign_in_with_email_and_password(
         os.environ['FIREBASE_EMAIL'], os.environ['FIREBASE_PWD'])
     self.auth_token = user['idToken']
     self.db = firebase.database()
     self._tags = None
Exemplo n.º 5
0
def get_refreshed_firebase_user(read_configuration):

    # Instantiate service
    #
    firebase = Firebase(get_firebase_configuration(read_configuration))

    # Get Firebase AUTH service
    #
    auth = firebase.auth()

    # Get current user
    #
    firebase_user = get_firebase_user(read_configuration)
    if firebase_user is not None:
        try:
            firebase_user = auth.refresh(firebase_user['refreshToken'])
            return firebase_user
        except Exception as ex:
            print("Error while refreshing user's access token : %s" % ex)
            return None
    else:
        return None
import os
API_BINANCE_KEY = os.getenv("API_BINANCE_KEY")
API_BINANCE_SECRET = os.getenv("API_BINANCE_SECRET")

from firebase import Firebase

firebaseConfig = {
    "apiKey": os.getenv("FIREBASE_API_KEY"),
    "authDomain": "pybot-bottrade.firebaseapp.com",
    "projectId": "pybot-bottrade",
    "storageBucket": "pybot-bottrade.appspot.com",
    "messagingSenderId": "966280251835",
    "appId": "1:966280251835:web:a9ceef709f806fee8cdc9e",
    "measurementId": "G-KN2EG9DBH4",
    "databaseURL": os.getenv("FirebaseDatabaseURL"),
    "serviceAccount":
    "pybot-bottrade-firebase-adminsdk-9em5u-123a2cfc0e.json"  # นำไฟล์ของท่านมาใส่เองด้วย
}

firebaseCleint = Firebase(firebaseConfig)
auth = firebaseCleint.auth()
# ใช้ Service account .json ในการ authenticate as admin ได้เลย
# สามารถดูตามวิดิโอในกลุ่มนะคับ
# user = auth.sign_in_with_email_and_password(os.getenv("FIREBASE_EMAIL_AUTH"), os.getenv("FIREBASE_PASSWORD"))

#ทดสอบ
if __name__ == '__main__':
    db = firebaseCleint.database()
    data = {"name": "TEST"}
    user = auth.refresh(user['refreshToken'])
    results = db.child("users").push(data, user['idToken'])
Exemplo n.º 7
0
if not firebase_admin._apps:
    cred = credentials.Certificate(os.getcwd() +
                                   '/uploads/storage_adminsdk.json')
    default_app = initialize_app(
        cred, {'storageBucket': os.getenv('STORAGE_BUCKET_URL')})

config = {
    "apiKey": os.getenv('API_KEY'),
    "authDomain": os.getenv('AUTH_DOMAIN'),
    "databaseURL": os.getenv('DATABASE_URL'),
    "storageBucket": os.getenv('STORAGE_BUCKET_URL')
}

firebase = Firebase(config)
auth = firebase.auth()

#===================================================================

#==================================================================
# MAIN DISPLAY

Page.title()
Page.login(auth)

if (Page.state):

    Page.highlights()
    Page.siteFunctions()
    Page.instagram()
Exemplo n.º 8
0
from firebase_admin import auth
from firebase import Firebase
from config.config import config

firebase = Firebase(config)

authCliente = firebase.auth()


class AuthUser:
    def __init__(self, email, password=None):
        self.email = email
        self.password = password

    def auth_user(self):
        try:
            # Se inicia session y se verifica la informacion
            user = authCliente.sign_in_with_email_and_password(
                self.email, self.password)
            info_user = self.getInformation(user['idToken'])

            # Se verifica si el email esta en estatus "Verificado"
            if (info_user['users'][0]['emailVerified'] == False):
                verified = {
                    'code': '401',
                    'response': {
                        'message':
                        'Debe validar su correo para poder hacer uso de esta cuenta',
                        'reason': 'not-verified'
                    }
                }
Exemplo n.º 9
0
import os
API_BINANCE_KEY = os.getenv("API_BINANCE_KEY")
API_BINANCE_SECRET = os.getenv("API_BINANCE_SECRET")

API_LINE_KEY = os.getenv("API_LINE_KEY")
API_CLIENT_SECRET = os.getenv("API_CLIENT_SECRET")
LINE_NOTIFY_TOKEN = os.getenv("LINE_NOTIFY_TOKEN")

LINE_BOT_ACCESS_TOKEN = os.getenv("LINE_BOT_ACCESS_TOKEN")
LINE_BOT_CHANNEL_SECRET = os.getenv("LINE_BOT_CHANNEL_SECRET")

from firebase import Firebase

firebaseConfig = {
    "apiKey": os.getenv("FIREBASE_API_KEY"),
    "authDomain": "bottrading-databse.firebaseapp.com",
    "databaseURL": os.getenv("DATABASE_URL"),
    "projectId": "bottrading-databse",
    "storageBucket": "bottrading-databse.appspot.com",
    "messagingSenderId": "1091910107557",
    "appId": "1:1091910107557:web:1606a1ddaa97fbc530284c"
}

firebaseClient = Firebase(firebaseConfig)
auth = firebaseClient.auth()
user = auth.sign_in_with_email_and_password(os.getenv("FIREBASE_EMAIL_AUTH"),
                                            os.getenv("FIREBASE_PASSWORD"))
Exemplo n.º 10
0
# Customized Versions of imported Libraries for Firebase

import json
from firebase import Firebase

jsonFile = open('./app/python_firebase/assets/FirebaseRESTKey.json')
firebaseConfig = json.load(jsonFile)

firebaseObj = Firebase(firebaseConfig)
fireAuth = firebaseObj.auth()
Exemplo n.º 11
0
def main():
    config = {
        "apiKey": "AIzaSyBkQ5z8Rs5IRP4lHoiWyXV9XVQHjAh-sEI",
        "authDomain": "a-eye-for-the-blind.firebaseapp.com",
        "storageBucket": "a-eye-for-the-blind.appspot.com",
        "databaseURL":
        "https://a-eye-for-the-blind-default-rtdb.firebaseio.com/",
    }
    uid = "^^^^^^^^^^^"  # unique user ID, must set before running
    email = '*****@*****.**'
    password = '******'
    firebase = Firebase(config)
    db = firebase.database()
    auth = firebase.auth()
    storage = firebase.storage()

    user = auth.sign_in_with_email_and_password(email, password)
    user = auth.refresh(user['refreshToken'])

    if uid == "" or email == "" or password == "":
        print("Please set user UID, email, or password in the lines above!")
        sys.exit()

    engine = pyttsx3.init()
    BATCH_SIZE = 1
    eval_num_threads = 2
    opt = TrainOptions().parse(
    )  # set CUDA_VISIBLE_DEVICES before import torch
    model = pix2pix_model.Pix2PixModel(opt)
    torch.backends.cudnn.enabled = True
    torch.backends.cudnn.benchmark = True
    best_epoch = 0
    global_step = 0
    model.switch_to_eval()
    video_list = 'D:/A-Eye For The Blind/2dtodepth/infile1/'
    save_path = 'D:/A-Eye For The Blind/2dtodepth/outfile/'
    uid = 'yQowLXfAMddiITuMFASMoKlSGyh1'
    # initialize the camera
    cam = cv2.VideoCapture(cv2.CAP_DSHOW)  # 0 -> index of camera
    x = 0
    while True:
        s, img = cam.read()
        cv2.imwrite("D:/A-Eye For The Blind/2dtodepth/infile1/filename.jpg",
                    img)  # save image
        # filename = uid + ' ' + time()
        storage.child(f"images/i{str(x)}.jpg").put(
            "D:/A-Eye For The Blind/2dtodepth/infile1/filename.jpg",
            user['idToken'])
        url = storage.child(f"images/i{str(x)}.jpg").get_url(user['idToken'])
        data = {f"i{str(x)}": f"{url}"}
        db.child(f"users/{uid}").child("images").update(data)
        video_data_loader = aligned_data_loader.DAVISDataLoader(
            video_list, BATCH_SIZE)
        video_dataset = video_data_loader.load_data()
        for i, data in enumerate(video_dataset):
            stacked_img = data[0]
            targets = data[1]
            output = model.run_and_save_DAVIS(stacked_img, targets, save_path)
            height, width, _ = output.shape
            width_cutoff = width // 2
            half1 = output[:, :width_cutoff]
            half2 = output[:, width_cutoff:]
            width_cutoff = width // 4
            s1 = half1[:, :width_cutoff]
            s2 = half1[:, width_cutoff:]
            s3 = half2[:, :width_cutoff]
            s4 = half2[:, width_cutoff:]
            commands = finalcommand(s1, s2, s3, s4)
            print(commands)
            if commands[1] == 0:
                if commands[0] == 0 and commands[2] == 0:
                    engine.say("STOP!")
                elif commands[0] == 0:
                    engine.say("Move right.")
                elif commands[2] == 2:
                    engine.say("Move left.")
                else:
                    engine.say("Move left.")
            engine.runAndWait()
        os.remove("D:/A-Eye For The Blind/2dtodepth/infile1/filename.jpg")
        x += 1
        if cv2.waitKey(33) == ord('a'):
            break
    cam.release()
Exemplo n.º 12
0
class IPFSDrive(Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.geometry("300x350")
        self.title("IPFS-Drive")

        mainframe = Frame(self)
        mainframe.pack(side="top", fill="both", expand=True)
        mainframe.grid_rowconfigure(0, weight=1)
        mainframe.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for F in (Start, Main, Authentication, Registration):
            frame = F(parent=mainframe, controller=self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.frames[Registration].next = Authentication
        self.frames[Start].next = Main
        self.frames[Main].prev = Start

        self.current_frame = None

        self.protocol("WM_DELETE_WINDOW", self.exit)

        self._working_dir_path = None
        self.init_working_dir()

        config = json.load(open("firebase.cfg"))
        self._firebase = Firebase(config)
        self._auth = self._firebase.auth()
        self._db = None
        self._ipfs = None
        self._root_dir_path = None
        self._encryption_password = None
        self._content = None
        self._event_observer = None
        self._sync = None

        self._logger = logging.getLogger()

        self._cipher = AESCipher()
        self._ipfs_client = IPFSClient(self._cipher, self._working_dir_path)
        self._ipfs_cluster = IPFSCluster()

        self.show_frame(Authentication)

    def show_frame(self, frame):
        self.current_frame = self.frames[frame]
        self.current_frame.tkraise()
        if isinstance(self.current_frame, Main):
            self.current_frame.on_raised()

    def get_frame(self, frame):
        return self.frames[frame]

    def get_auth(self):
        return self._firebase.auth()

    def get_content(self):
        return self._content

    def set_root_dir_path(self, root_dir_path):
        self._root_dir_path = root_dir_path.replace(os.sep, '/')

    def init_working_dir(self):
        self._working_dir_path = os.path.join(os.getcwd(), "working_dir")
        if not os.path.exists(self._working_dir_path):
            os.mkdir(self._working_dir_path)
            ctypes.windll.kernel32.SetFileAttributesW(self._working_dir_path, 2)

    def init_db(self, uid, token):
        self._db = Db(self._firebase.database(), uid, token)

    def init_content(self):
        self._content = Content(self._root_dir_path, self._db)

    def init_cipher_key(self, encryption_password):
        self._cipher.create_key(encryption_password)

    def init_ipfs(self):
        self._ipfs = IPFS()
        while not self._ipfs.is_ready():
            time.sleep(0.5)

    def init_sync(self):
        self._sync = Sync(self._root_dir_path, self._working_dir_path, self._content, self._db, self._ipfs_client,
                          self._cipher)

    def init_event_monitoring(self):
        event_handler = EventHandler(self._ipfs_client, self._ipfs_cluster, self._content, self._root_dir_path)
        self._event_observer = Observer()
        self._event_observer.schedule(event_handler, self._root_dir_path, recursive=True)
        self._event_observer.start()

    def synchronize(self):
        self._sync.start()

    def start_listening_for_changes(self):
        self._sync.start_listening()

    def add_root_dir(self, start_time):
        for path in os.listdir(self._root_dir_path):
            full_path = os.path.join(self._root_dir_path, path).replace(os.sep, '/')
            if os.path.getctime(full_path) >= start_time:
                continue
            if os.path.isfile(full_path):
                file = File(full_path)
                hash = self._ipfs_client.add_file(file)
                self._content.add(file.path, hash)
            elif os.path.isdir(full_path):
                content_list = self._ipfs_client.add_dir(Directory(full_path))
                self._content.add_list(content_list)
            self._ipfs_cluster.pin(self._content[full_path])

    def get_content_tree(self):
        db_content = self._db.get_content()

        root_dir = IPFSDirectory('.', None)

        if db_content is None:
            return root_dir

        for k, v in db_content.items():
            name = base64.b64decode(k).decode()
            if '.' in name:
                file = IPFSFile(name, v, root_dir)
                root_dir.add_file(file)
            else:
                dir = IPFSDirectory(name, v, root_dir)
                walk(dir)
                root_dir.add_dir(dir)

        return root_dir

    def attach(self, obj):
        self._content.attach(obj)
        self._logger.debug("Attached to content")
        if self._sync:
            self._sync.attach(obj)
            self._logger.debug("Attached to sync")

    def run(self):
        self.mainloop()

    def exit(self):
        if self.current_frame.close():
            if self._event_observer:
                self._event_observer.stop()
                self._event_observer.join()
            shutil.rmtree(self._working_dir_path)
            self.destroy()
Exemplo n.º 13
0
from django.contrib import auth

config = {
    "apiKey": "AIzaSyCaxK3AcB27ms-lCXVc7VaQPgtFjstkzK8",
    "authDomain": "ecom-6cab2.firebaseapp.com",
    "databaseURL": "https://ecom-6cab2-default-rtdb.firebaseio.com",
    "projectId": "ecom-6cab2",
    "storageBucket": "ecom-6cab2.appspot.com",
    "messagingSenderId": "1024220380197",
    "appId": "1:1024220380197:web:d5ec37cfb63ba2028d53cc",
    "measurementId": "G-3E6TRQREQV"
}

firebase = Firebase(config)

authe = firebase.auth()

database = firebase.database()


def signIn(request):
    return render(request, "signIn.html")


def postsign(request):
    email = request.POST.get('email')
    passw = request.POST.get('pass')
    try:
        user = authe.sign_in_with_email_and_password(email, passw)
    except:
        message = "invalid credentials"
Exemplo n.º 14
0
import json
from firebase import Firebase
from google.cloud import firestore
from google.oauth2.credentials import Credentials

config = {
    "apiKey": "AIzaSyDFL1HQcIwmjQn1AKLFrITEMntMArIJFZA",
    "authDomain": "bprotective-6c0a5.firebaseapp.com",
    "databaseURL":
    "https://firestore.googleapis.com/v1/projects/bprotective-6c0a5/databases/",
    "projectId": "bprotective-6c0a5",
    "storageBucket": "bprotective-6c0a5.appspot.com",
}

firebase = Firebase(config)

response = firebase.auth().sign_in_with_email_and_password(
    "*****@*****.**", "pastword")
cred = Credentials(response['idToken'], response['refreshToken'])
db = firestore.Client("bprotective-6c0a5", cred)
Exemplo n.º 15
0
def login():

    # Check if we already have user data in JARVIS_HOME configuration file
    #
    read_configuration = jarvis_config.get_jarvis_configuration_file()
    if read_configuration is None:
        print("No configuration file found in your Jarvis Home directory...")
        print("Please run \"jarvis config\" to make sure Jarvis SDK is properly configured.")
        return False

    # Check if we have Jarvis Firebase information
    #
    jarvis_firebase_config = get_firebase_configuration(read_configuration)
    if jarvis_firebase_config is None:
        return False

    # Instantiate service
    #
    firebase = Firebase(jarvis_firebase_config)

    # Get Firebase AUTH service
    #
    auth = firebase.auth()

    # Try to authenticate
    #
    firebase_user = None

    # Ask user info to authenticate through firebase
    #
    print("Please provide your email address. Default -> " +
            read_configuration["user_email"] + " : ", end='', flush=True)
    user_email = input().strip()
    if not user_email:
        user_email = read_configuration["user_email"]

    user_password = getpass.getpass("Please provide your password : "******"error"]["message"]).strip()

            if error == "INVALID_EMAIL":
                print("The user email address provided is invalid/malformed.")
                return False

            elif error == "EMAIL_NOT_FOUND":
                print("The user \"" + user_email + "\" does not exists in Jarvis database.")
                email_not_found = True

            elif error == "INVALID_PASSWORD":
                print("The password provided is invalid")
                return False
            else:
                print("Error unknown : \n%s" % ex.strerror)
                return False
                    
    # Create user if needed
    #
    if email_not_found is True:
        while True:
            print("Do you want to create the account \"" + user_email + "\" on Jarvis Platform ? y/n : ", end='', flush=True)
            user_entry = input().strip()
            if user_entry == "n":
                return True
            elif user_entry == "y":

                # Get a password
                #
                while True:
                    user_password = getpass.getpass("Please provide a password : "******"Please retype your password : "******"The password you retyped is different from the first one, please retry ...")
                    else:
                        break

                # Try to create users
                #
                try:
                    firebase_user = auth.create_user_with_email_and_password(user_email, user_password)
                    auth.send_email_verification(firebase_user['idToken'])
                    print("\nThe account \"" + user_email + "\" has been created successfully.")
                    print("Please check your email address to validate your account creation.\n")

                except Exception as ex:
                    print("An error occurred while attempting to create a new user.")
                    print(ex)
                break

    # Save user in configuration file
    #
    print("Saving configuration ...")
    read_configuration["firebase_user"] = firebase_user
    jarvis_config.set_jarvis_configuration_file(read_configuration)

    return True
Exemplo n.º 16
0
from django.contrib import auth

Config = {
    'apiKey': "AIzaSyCN8RfCVP2gT-MW2ryZTUEAjXVFsw_qqjg",
    'authDomain': "authn-2dd06.firebaseapp.com",
    'databaseURL': "https://authn-2dd06.firebaseio.com",
    'projectId': "authn-2dd06",
    'storageBucket': "authn-2dd06.appspot.com",
    'messagingSenderId': "1078584542869",
    'appId': "1:1078584542869:web:ba520da0ed056ff47d3d9c",
    'measurementId': "G-58S94BH5NE"
}

default_app = Firebase(Config)

authi = default_app.auth()
databse = default_app.database()


def signin(request):
    return render(request, template_name="signIn.html")


def postsign(request):
    email = request.POST.get('email')
    passw = request.POST.get('password')
    try:
        user = authi.sign_in_with_email_and_password(email, passw)
    except:
        message = "invalid credentials"
        return render(request, "signIn.html", {'messa': message})