jeudi 26 janvier 2017

How do I authenticate against Firebase

I'm following this guide on how to write to my database with an authenticated user. I have set the rules properly and am able to post if all the writes are true just fine. When I pass the oauthToken I get when I follow this guide I get "Invalid claim "kid" in auth header". I've seen other questions with this result but I don't think they're doing the exact same things as I am nor are they using the same language.

So how do I authenticate properly? I can get the token and everything else just fine.

Current rule set:

"rules": {
    "location": {
        "$user_id": {
            ".read": all,
            ".write": "$user_id === auth.uid"


My code:

    private function submitNewData(localId:String, authToken:String):void
        var data:Object = new Object();
        data.location = "w0.0rld";
        data.description = "hello";

        var request:URLRequest = new URLRequest("https://" + FIREBASE_PROJECT_ID + "" + uid + ".json?auth=" + authToken); = JSON.stringify(data);
        request.method = URLRequestMethod.POST;

        var loader:URLLoader = new URLLoader();
        loader.addEventListener(Event.COMPLETE, entrySent);

    private function entrySent(
        trace(; //Invalid claim 'kid' in auth header

Aucun commentaire:

Enregistrer un commentaire