den*_*nis 11 swagger firebase google-oauth swagger-ui firebase-authentication
任何人都可以为firebase身份验证提供Swagger安全定义的工作示例吗?
在后端,使用firebase管理SDK验证firebase ID令牌:
import * as admin from 'firebase-admin';
await admin.auth().verifyIdToken(idToken);
Run Code Online (Sandbox Code Playgroud)
Swagger安全定义中的值应该为firebase获取正确的ID令牌?
"securityDefinitions": {
"firebase": {
"authorizationUrl": "https://accounts.google.com/o/oauth2/v2/auth",
"flow": "implicit",
"type": "oauth2",
"x-google-issuer": "https://securetoken.google.com/MY-PROJECT-ID",
"x-google-jwks_uri": "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com",
"x-google-audiences": "MY-CLIENT-ID",
"scopes": {
"https://www.googleapis.com/auth/firebase": "Firebase scope"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我确实得到了一个令牌,然而,firebase管理员SDK说它无效:
解码Firebase ID令牌失败.确保传递了代表ID令牌的整个字符串JWT
不确定这是因为错误的范围或令牌类型......
使用 Firebase 对用户进行身份验证/配置 OpenAPI 文档对此进行了解释。
给定的示例绝对没有任何authorizationUrl
orscopes
部分:
securityDefinitions:
firebase:
authorizationUrl: ""
flow: "implicit"
type: "oauth2"
# Replace YOUR-PROJECT-ID with your project ID
x-google-issuer: "https://securetoken.google.com/YOUR-PROJECT-ID"
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
x-google-audiences: "YOUR-PROJECT-ID"
Run Code Online (Sandbox Code Playgroud)
并且此firebase
安全定义还需要添加到security
API 或方法级别的部分中:
security:
- firebase: []
Run Code Online (Sandbox Code Playgroud)
阅读“JWT 验证故障排除”可能会有所帮助。
归档时间: |
|
查看次数: |
749 次 |
最近记录: |