これらのコードスニペット(firebase doc)では、バックエンドサーバでの認証にuser.getUid()を使用していません。代わりにFirebaseUser.getToken()を使用してください。firebase認証でバックエンドサーバとの認証にgetUid()を使用できない理由
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
// Name, email address, and profile photo Url
String name = user.getDisplayName();
String email = user.getEmail();
Uri photoUrl = user.getPhotoUrl();
// The user's ID, unique to the Firebase project. Do NOT use this value to
// authenticate with your backend server, if you have one. Use
// FirebaseUser.getToken() instead.
String uid = user.getUid();
}
getUid() A unique user ID, intended as the user's unique key across all providers.
getToken() The Firebase authentication token for this session.
私の要件はです。
- まず、ユーザーにfirebase認証方法(電子メールとパスワード)を登録します。
- 私は文字列を保存しますuid = user.getUid();登録が成功すると自分のバックエンドサーバーで
- ユーザークレジット情報は、ユーザーの残高がキーuser.getUid()として自分自身のバックエンドサーバーに保存されていると言います。
- ユーザーは電子メールとパスワードでサインインし、彼の残高を尋ねます。
- firebaseからuser.getUid()を取得し、一致するレコードがユーザーにバランスを返す場合は、自分のレコードと一致させます。
getUid()は一意のユーザーIDですが、この値を使用してバックエンドサーバーで認証しないでください。
なぜですか?バックエンドサーバーでの認証にgetUid()を使用できないのはなぜですか?
質問に対する回答が見つかりましたか?私はまったく同じことをやろうと思っています。私たちが持っている考え方のプロセスには問題はありません – Snake