针对服务器+ Xcode 8.1的Swift + Vapor框架
我正在尝试读取Firebase实时数据库,向我的数据库发出HTTP请求,但我得到的权限被拒绝。
以下是步骤:
服务器收到的访问令牌将get请求发送到
我收到"Permission denied",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"
}
发布于 2016-11-27 17:06:22
scope
密钥缺少值https://www.googleapis.com/auth/userinfo.email
let jwtClaimSet =
["iss":"firebase-adminsdk-kxx5h@fir-30c9e.iam.gserviceaccount.com",
"scope": "https://www.googleapis.com/auth/firebase.database
https://www.googleapis.com/auth/userinfo.email",
"aud":"https://www.googleapis.com/oauth2/v4/token",
"exp": expDate,
"iat": iatDate]
发布于 2016-11-26 19:30:01
发布于 2016-11-25 17:50:04
headers: ["Authorization":"Authorization: Bearer \(accesstoken)"],
应该是
headers: ["Authorization":"Bearer \(accesstoken)"],
https://stackoverflow.com/questions/40810233
复制相似问题