Can't access FireBase Database via HTTP/REST error 403 Forbidden

前端 未结 3 1799
深忆病人
深忆病人 2020-11-28 12:31

Swift + Vapor framework for server + Xcode 8.1

I am trying to read Firebase Realtime Database making HTTP requests to my DB, but I get permission denied.

Th

相关标签:
3条回答
  • 2020-11-28 12:37
    headers: ["Authorization":"Authorization: Bearer \(accesstoken)"],
    

    should be

    headers: ["Authorization":"Bearer \(accesstoken)"],
    
    0 讨论(0)
  • 2020-11-28 12:39

    The scope key was missing value 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]
    

    I found the answer browsing google groups here

    0 讨论(0)
  • 2020-11-28 12:56

    TLDR; Try placing auth=<TOKEN> in your query string instead of using the authorization header.


    The Firebase documentation is unclear on how this works. According to the documentation, there are three methods that should work.

    1. auth=<TOKEN> in query string (link)
    2. access_token=<TOKEN> in query string (link)
    3. Authorization: Bearer <TOKEN> in request header (link)

    I'm not convinced that all three methods do actually work however. I'm using method 1 in my application, so I know that one works for sure.

    0 讨论(0)
提交回复
热议问题