如何使用KTOR 2.0使用Firebase管理员
有人知道如何将这些代码转换为KTOR 2.0吗?
Does anyone have an idea how to convert these codes to ktor 2.0.
https://gist.github.com/togisoft/d1113a83eeb1d6b52031f77fe780ce48
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果某人需要看到 Aleksei的答案,我创建了a 示例存储库。
我确实对另一个答案进行了一些调整,因为实现错误缺少了原始要旨的正确消息传递。
然后在项目中实际使用
Application
上创建了一个扩展功能。在在KTOR上安装Firebase身份验证插件之前,请确保Firebase Admin SDK已使用凭据初始化。最终用身份验证功能包裹路线:
If someone needs to see a complete sample of Aleksei's answer, I created a sample repository.
I did make some slight tweaks to the other answer as the implementation error was missing the correct messaging from the original gist.
Then to actually use in your project created an extension function on
Application
. Be sure that the Firebase Admin SDK has been initialized with credentials before installing the Firebase authentication plugin on Ktor.Finally wrap a route with the authentication function:
转换为KTOR 2.0。*代码如下:
The converted to Ktor 2.0.* code is the following: