question

traineegurgaon avatar image
traineegurgaon asked

Playfab how make basic auth request from cloudscript?

I want to make a request of method type post with baisc auth.

Here is the code which doesn't work:-

var clientId = "admin"; var clientSecret = "password";

var authorizationBasic = $.base64.btoa(clientId + ':' + clientSecret);

var request = new XMLHttpRequest(); request.open('POST', 'http://www.hggh.com/getUserName', true);

request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); request.setRequestHeader('Authorization', 'Basic ' + authorizationBasic); request.setRequestHeader('Accept', 'application/json'); request.send("username=adminuser&password=Work@1234&grant_type=password"); request.onreadystatechange = function () { if (request.readyState === 4) { alert(request.responseText); } };

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

·
comc avatar image
comc Deactivated answered

is it possible for you to use http.request instead of newXMLHttpRequest here?

Is the sample CloudScript in your project working OK?

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.