romkij
started a topic on Thu, 03 September 2015 at 1:39 PM
Hello!
Can you add in "http.request" possibility insert custom headers?
Example case: database in Microsoft Azure, need provide application key for data manipulating.
2 Comments
lango said on Wed, 23 September 2015 at 12:44 AM
I would also like the option to add custom headers to http.request in cloud scripts.
My reason is calling third party API's often requires authentication.
For example, I'm implementing a custom login with Clever. The first response they give includes a code, which must be exchanged for an access token. The code must be passed inside the header like so:
Authorization: Bearer xxxxxxxxxx
https://dev.clever.com/instant-login/bearer-tokens
Also, I want to keep my client secret hidden inside my app, not visible in JS on my website.
Brendan Vanous said on Wed, 23 September 2015 at 7:08 PM
I see that the documentation is out of date, so I've asked our SDK team to check on the auto-update process.
In addition to the parameters listed (http://cloudscript.playfab.com/classes/http.html#method_request), we do support headers, specifically for scenarios such as you describe (bearer tokens).
So for example, you could add a bearer token header to the call like this in your Cloud Script:
var headers = {};
headers["Authorization"] = "Bearer "+ bearerAccesToken;
var response = http.request(url,method,contentBody,contentType,headers);
Brendan
I like the option of adding custom settings. thanks you for the information.
I would like this costume settings in my project eduhelphub.com and hoping for getting a great solution.
Share your great idea, or help out by voting for other people's ideas.
No one has followed this idea yet.