是否仍然可以在Firebase 3中对令牌进行服务器端验证?
我们使用现有的身份验证系统(使用服务帐户)在运行Golang的服务器上生成自定义令牌(JWT).令牌在iOS客户端上使用
FIRAuth.auth()?.signInWithCustomToken(customToken)
Run Code Online (Sandbox Code Playgroud)
直到那里一切正常.但是当我们将客户端令牌传递给从以下位置检索的服务器时
FIRUser.getTokenWithCompletion({ token, error in ..})
Run Code Online (Sandbox Code Playgroud)
我们无法验证它.JWT令牌使用RS256签名,并且有一个我们无法识别的header.kid.服务帐户(用于签署自定义令牌)的公钥不验证客户端令牌.验证客户端令牌是否需要公钥?
我知道可以使用Java或Javascript中的"verifyIdToken"调用来验证客户端令牌,但我们希望能够使用标准JWT库在Golang中执行此操作.
这一切在Firebase 2中运行良好(使用HS256和Firebase秘密).
用于服务器+ Xcode 8.1的Swift + Vapor框架
我正在尝试阅读Firebase实时数据库向我的数据库发出HTTP请求,但我得到了许可被拒绝.
以下是这些步骤:
1.使用从"console.developers.google.com"下载的密钥创建JWT签名
2.将POST请求发送到OAuth2服务器并获取访问令牌
3.将GET请求发送到firebase数据库,并从中接收访问令牌OAuth2服务器.
我得到"权限被拒绝",HTTP/1.1 403禁止
// the header of the JSON Web Token (first part of the JWT)
let headerJWT = ["alg":"RS256","typ":"JWT"]
// the claim set of the JSON Web Token
let jwtClaimSet =
["iss":"firebase-adminsdk-kxx5h@fir-30c9e.iam.gserviceaccount.com",
"scope":"https://www.googleapis.com/auth/firebase.database", //is this the correct API to access firebase database?
"aud":"https://www.googleapis.com/oauth2/v4/token",
"exp": expDate,
"iat": iatDate]
drop.get("access") { request in
var accesstoken = "ya29.ElqhA-....XXXX"
let responseFirebase = try drop.client.get("https://fir- 30c9e.firebaseio.com/data/Users.json",
headers: ["Authorization":"Bearer \(accesstoken)"],
query: [:])
print("FirebaseResponse_is \(responseFirebase)")
return "success" …Run Code Online (Sandbox Code Playgroud) 更改了firebase授权系统后,我正在尝试从google auth服务器中检索c#中的访问令牌.
根据新文档:https://firebase.google.com/docs/reference/rest/database/user-auth#section-api-usage
我在c#中创建了类似的东西:
using Google.Apis.Auth.OAuth2;
[...]
async Task<string> GetToken()
{
GoogleCredential credential;
using (var stream = new System.IO.FileStream("gckey.json",
System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream).CreateScoped(
new string[] { "https://www.googleapis.com/auth/firebase.database" }
);
}
ITokenAccess c = credential as ITokenAccess;
return await c.GetAccessTokenForRequestAsync();
}
Run Code Online (Sandbox Code Playgroud)
gckey.json是从Google Developer Console下载的特定firebase项目的密钥文件.
代码工作正常,但它返回不与firebase一起使用的令牌,我试过:
https://fiery-torch-xxxx.firebaseio.com/.json?access_token=retrived token
但我收到:
"error" : "Permission denied."
我究竟做错了什么?或者我错过了什么?