英文:
Would call `firebaseUser.getIdToken(refresh: true);` every app start be a problem?
问题
我正在尝试修复我发布的问题 https://stackoverflow.com/questions/59590938/firestore-rules-request-auth-token-firebase-identitiesphone-not-update-on-io
目前通过调用 firebaseUser.getIdToken(refresh: true);
来进行修复,以便在电话验证和应用程序启动后进行刷新更新。
每次应用程序启动都调用 firebaseUser.getIdToken(refresh: true);
会有问题吗?我认为如果大量用户不断使用服务器获取 ID 令牌,可能会导致服务器超载或其他问题?
英文:
I am trying to fix the question I post https://stackoverflow.com/questions/59590938/firestore-rules-request-auth-token-firebase-identitiesphone-not-update-on-io
Currently fix by call firebaseUser.getIdToken(refresh: true);
to make refresh update after phone verified and app started.
Would call firebaseUser.getIdToken(refresh: true);
every app start be a problem? I think maybe if bunch of users keep fetching ID Token with server will causing server overload or something?
答案1
得分: 1
只返回翻译好的部分:
虽然我认为这不会成为一个问题,但这并不是获取最新ID令牌的最佳方式。如果你只想知道最近获取的ID令牌,可以使用addIDTokenDidChangeListener()来接收Firebase SDK在自动刷新ID令牌时(每小时一次)提供的任何更新。
通常,只有在你知道ID令牌中的自定义声明或其他信息在服务器上发生了变化,并且你需要重新加载这些信息以供客户端使用时,才会强制刷新令牌。如果这不是你的情况,你可能不需要强制重新加载。
英文:
While I don't think it would be a problem, it's not really the best way to go about getting the most recent ID token. If you just want to know the most recently fetched ID token, you can use addIDTokenDidChangeListener() to receive any updates to the ID token whenever the Firebase SDK automatically refreshes it (every hour).
You typically only force a refresh token if you know the custom claims or other information in the ID token have changed on the server, and you need to reload those for use on the client. If this is not your situation, you probably don't need to force a reload.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论