mardi 16 juillet 2019

Firebase: log in / sign up via GitHub

I want to allow user to sign in to my web app via GitHub using Firebase.

I create a new auth using this code in my python server:

python

 users = [
        auth.ImportUserRecord(
            uid=submission["id"],
            display_name=submission["display_name"],
            email=submission["email"],
            provider_data=[  # user with Google provider
                auth.UserProvider(
                    uid=submission["display_name"],
                    email=submission["email"],
                    provider_id='github.com'
                )
            ],
        ),
    ]
    try:
        result = auth.import_users(users)
    except Exception as e:

Then the user is displayed in the authentication GUI in the Firebase console. The problem comes when I want to sign in the user. By using the next code:

javascript

const provider = new firebase.auth.GithubAuthProvider();
    firebase.auth().signInWithPopup(provider).then((result) => {
    }).catch(function (error) {
});

I get the next error: "An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.". I surely miss something, but I can't figure out how the whole process works. How is the link made between the previous code and the sign in action? How does Firebase recognize the user?




Aucun commentaire:

Enregistrer un commentaire