question

Aphix avatar image
Aphix asked

Unauthorized Response when trying to get user data

I am trying to set user data for testing purposes using unreal engine playfab in Blueprints, however I am recieving this error while getting and setting player data:

Response : {"code":401,"status":"Unauthorized","error":"NotAuthenticated","errorCode":1074,"errorMessage":"Missing or invalid X-SecretKey HTTP header"}

Is there an obvious answer to this? I just started using Playfab so I am unsure what this error code means.

unreal
10 |1200

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

Aphix avatar image
Aphix answered

I must have used the incorrect api in this project because once I tried again, except with the client api, everything works. If anyone else has this issue, make sure all api calls are from the client api.

10 |1200

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

Sarah Zhang avatar image
Sarah Zhang answered

Could you please tell us which one API did you invoke? Theoretically, only when you call the Server API or Admin API without providing the developer secret key, will this error be returned. According to your previous question, it seems you are developing a client program using Unreal. If so, we would suggest you don’t call the Server API or Admin API on the client for security reasons. Client API UpdateUserData can achieve your requirement. You can double-check whether you have called the Client API correctly.

5 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.

Aphix avatar image Aphix commented ·

@Sarah Zhang I am currently calling the admin function on the server, which is invoked by a client rpc. I want this data to only be editable by the server, however I am unsure how secure it is to have clients edit their own data.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Aphix commented ·

If the question is targeted for the server logic, you need to add the secret key in the project.

0 Likes 0 ·
Aphix avatar image Aphix commented ·

@Sarah Zhang I have discovered that reading both public and private data will give me back the 401 error code. Once again, I am calling this using the admin api over the server, which the client invokes. I am not calling the Client API so that clients cannot configure their updated data.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Aphix commented ·

Thanks for the clarification. If you are developing the server using Unreal. To call the Admin API or Server API, you need to add the developer secret key in the project.

0 Likes 0 ·
Aphix avatar image Aphix Sarah Zhang commented ·

@Sarah Zhang Thank you for the quick response! I am including the developer secret key in my project, however I need to manually set it in the authentication context because setting it in the project settings caused an engine crash. I believe there is a way to manually set settings by default however, so I will get back when I try that out.

0 Likes 0 ·

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.