Idea

brendan avatar image
brendan suggested

Add custom headers in CloudScript - http.request

10 |1200

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

2 Comments

·
brendan avatar image
brendan commented

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

10 |1200

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

oliver avatar image
oliver commented

I like the option of adding custom settings. thanks you for the information.

1 comment
10 |1200

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

oliver avatar image oliver commented ·

I would like this costume settings in my project eduhelphub.com and hoping for getting a great solution.

0 Likes 0 ·

Write a Comment

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

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.

相关的想法