question

stepup4project avatar image
stepup4project asked

Sending data to Firebase from PlayFab

I've been using the following cloud script code to try to add data to my firebase db. I generated a service account key in order to do so. I'm not quite sure what needs to be placed in the header. Also if any permissions need to set up on firebase. I just tried to follow a similar example from this forum.

The error message returns "Unauthorized Request"

handlers.testFirebase = function(args) {

var headers = { "Authorization": "Bearer " + *private key from service account* };

var body = { test: "it worked"};

var url = "https://xxxxxx.firebaseio.com/users.json";

var content = JSON.stringify(body);

var httpMethod = "POST"; var contentType = "application/json"; var response = http.request(url, httpMethod, content, contentType, headers);

return response;

}

Player Data
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
pfnathan avatar image
pfnathan answered

What you are trying to accomplish is not a native feature to PlayFab; you are mainly trying to make an HTTP request via Cloud Script to Firebase. While we do provide the ability to make Web API calls from Cloud Script via HTTP request, we cannot support those external services ourselves. You would need to work with the owner of the service in question. In this case, if the only thing necessary to make a call to a Firebase Web API endpoint is the Authorization header, we do not have a good way to debug why you're getting an "unauthorized" error back.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.