Hello there,
This not a cross post.
I have been working on a small prototype with firebase and am facing some auth issues I can not explain.
First, I have a service account setup with the right firebase JSON file. I use that to make my backend service preset some data.
I also made sure to grand the editor permission to this Google APIs service account. This step works. I can set push data from the server.
"type": "service_account",
"project_id": "firepad-testxxxxx",
"private_key_id": "6402cbccc51d06ba1bc7b5xxxxxxxxxxxx",
"private_key": "-----BEGIN PRIVATE KEY----- xxxxxxx -----\n",
"client_id": "105780162380553xxxxx",
}
def create_custom_token(uid, user_type):
exp = datetime.timedelta(minutes=60)
return jwt.generate_jwt(payload, RSA_PRIVATE, 'RS256', exp)
print 'Error creating custom token: ' + e.message
Once I get the token for my test user alice (uid) I pass it to the rendered html page.
// Initialize the Firebase SDK.
firebase.initializeApp({
apiKey: '{{ FIREBASE_API_KEY }}',
databaseURL: '{{ FIREBASE_DB }}',
storageBucket: {{ FIREBASE_STORAGE }}'
});
var token = "{{ custom_token }}";
firebase.auth().signInWithCustomToken(token).catch(function(error) {
console.log(error);
});
The JS console complains the following:
https://www.evernote.com/l/AtnQNCJc_V5AZISEM0kYYEnA8qcRsXAFjw8firebase.js:276 FIREBASE WARNING: Provided authentication credentials are invalid. This usually indicates your FirebaseApp instance was not initialized correctly. Make sure your apiKey and databaseURL match the values provided for your app at
https://console.firebase.google.com/, or if you're using a service account, make sure it's authorized to access the specified databaseURL and is from the correct project.
When I did into the requests I see a first 200 OK POST to:
https://securetoken.googleapis.com/v1/token?key=AIzaSyDCxxxxxxxxxxxxxxxxxx{
"access_token": "eyJhbGciOiJSUzI1xxxxxxxxx", // <- seems to be our custom token?
"expires_in": "3600",
"token_type": "Bearer",
"refresh_token": "AGl2vTQuxxxxxxxxxxx",
"id_token": "eyJhbGciOiJSUzI1xxxxxxxxxx",
"user_id": "alice",
"project_id": "10850xxxxxxx"
}
I am running my tests on a page served by a small Python webserver on localhost:8800. localhost is part of the OAuth redirect domains on firebase.
I am running out of ideas.