我正在 linkedin-auth-example 的帮助下将 LinkedIn 和 Instagram 登录添加到我的应用程序中。这很好用。但我想通过登录来设置提供商名称。知道如何设置吗? 将用户设置为,
async function createFirebaseAccount(linkedinID, displayName, photoURL, email, accessToken) {
// The UID we'll assign to the user.
const uid = `linkedin:${linkedinID}`;
// Save the access token tot he Firebase Realtime Database.
const databaseTask = admin.database().ref(`/linkedInAccessToken/${uid}`).set(accessToken);
// Create or update the user account.
const userCreationTask = admin.auth().updateUser(uid, {
displayName: displayName,
photoURL: photoURL,
email: email,
emailVerified: true
}).catch((error) => {
// If user does not exists we create it.
if (error.code === 'auth/user-not-found') {
return admin.auth().createUser({
uid: uid,
displayName: displayName,
photoURL: photoURL,
email: email,
emailVerified: true
});
}
throw error;
});
// Wait for all async task to complete then generate and return a custom auth token.
await Promise.all([userCreationTask, databaseTask]);
// Create a Firebase custom auth token.
const token = await admin.auth().createCustomToken(uid);
console.log('Created Custom token for UID "', uid, '" Token:', token);
return token;
}
我正在阅读有关 AuthProviderConfig 的内容但不太确定如何使用它。有什么例子吗? 提前致谢。
最佳答案
Firebase 身份验证目前实际上仅支持少数身份提供商,例如 Google、Facebook、Twitter 和 GitHub,如所述 here .
如果您想使用您提到的任何其他提供商,您将需要使用 custom tokens .
我还将附上有关如何使用 Instagram 设置 Firebase 的更多阅读内容 here .
我希望这会有所帮助。
关于javascript - 如何在 firebase 登录或登录中设置或添加自定义提供程序名称,例如 linkedin、instagram?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59127164/