nhorvath / Pyrebase4

A simple python wrapper for the Firebase API. ⛺
254 stars 63 forks source link

'str' object has no attribute 'sign_in_with_email_and_password' #1

Closed gabrielemaffoni closed 5 years ago

gabrielemaffoni commented 5 years ago

Hi! I'm trying to login to existing user accounts. I am sure everything is setup correctly (python 3.5, Auth Sign In enabled in my Firebase). However, I keep having the same problem over and over: 'str' object has no attribute 'sign_in_with_email_and_password(email, password)'.

here's the code:

def sign_in():
    global auth
    global user
    email = input("Please, enter your email")
    password = input("Please, enter your password")
    user = auth.sign_in_with_email_and_password(email, password)
    get_user_id(user)

I can't seem to find a solution. Any help?!

nhorvath commented 5 years ago

auth is not merely a global variable it's a reference to the firebase authentication object. You should read the readme of this project.

import pyrebase

config = {
  "apiKey": "apiKey",
  "authDomain": "projectId.firebaseapp.com",
  "databaseURL": "https://databaseName.firebaseio.com",
  "storageBucket": "projectId.appspot.com"
}

firebase = pyrebase.initialize_app(config)

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