question

darrenbowen avatar image
darrenbowen asked

Cloud Script - http.request internal error with custom headers containing a semicolon

Hello.

I'm attempting to create a cloud script handler which communicates with an external HTTPS API. However when I make the request using the http.request API I am getting an internal error back from PlayFab (it looks like the request isn't making it as far as being sent out)

"result": {
    "responseContent": null,
    "httpStatus": null,
    "httpStatusCode": 0,
    "requestError": "InternalError"
},
...

"Error": {
  "Error": "CloudScriptHTTPRequestError",
  "Message": "The script made an external HTTP request, which returned an error. See the Error logs for details.",
  "StackTrace": "Error\n    at TestRequest (XXX-main.js:469:25)"
}

The error seems to be related to the custom authorization header that the external API requires. If I remove the header altogether I get an unauthorised response back from the external API.

For reference, the API requires a custom Authorization header in the AWS Signature Version 4 format. An example of the header is as follows:

Authorization: AWS4-HMAC-SHA256 Credential=BKIAROSFODNN7EXAMPLE/20170913/eu-west-1/xf/aws4_request,SignedHeaders=host;range;x-amz-date,Signature=fe5f80f77d5fa3beca038a248ff027d0445342fe2855ddc963176630326f1024

I did some further debugging and noticed that it appears to be the semi-colons in the header which cause the problem, if they are removed then the request is sent (it returns a fail from the external service because the header is no longer valid, but gets past the InternalError).

Is this a bug in PlayFab perhaps or the underlying http library that you use (any implementation details that you could share to help us track down the issue?)

CloudScript
10 |1200

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

brendan avatar image
brendan answered

This has been fixed - please let us know if you're still seeing any issues.

4 comments
10 |1200

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

darrenbowen avatar image darrenbowen commented ·

@Brendan - many thanks I can confirm that the updated version now works correctly.

0 Likes 0 ·
darrenbowen avatar image darrenbowen commented ·

@Brendan - Many thanks, I can confirm that the fix is working here.

0 Likes 0 ·
thelastvertex avatar image thelastvertex darrenbowen commented ·

@darrenbowen I hope you don't mind me digging up this thread, It doesn't look like I can send a user a private message.

I came across this thread attempting to find a solution for AWS Requests signature errors as can be seen here: https://community.playfab.com/questions/25324/encryption-for-dynamodb-access-in-cloud-scripting.html

I'm curious if you got AWS Requests working from cloud script? If so would you be willing to share some details?

0 Likes 0 ·
brendan avatar image brendan thelastvertex commented ·

Sorry for the delay - this got a bit buried. The recommendation is that developers look at using Azure Functions, if they need to make AWS calls to query DynamoDB. We'll have Azure Functions integrated into PlayFab's Game Manager shortly, but the capability does work fine in that service.

0 Likes 0 ·
brendan avatar image
brendan answered

We're actually looking into the way the library we use handles headers as part of another open question on authorization headers, so yes, I do believe you are correct. We'll be updating here with more information on this as soon as we can.

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.