Sign In Register

How can we help you today?

Start a new topic
Answered

Is it possible to get Leaderboard data with unauthenticated REST call?

 Hi,


I would like to show some global leaderboards integrated into my website. I see that `LeaderboardDataRequest` would be the request I need, I thought using it via the REST API (https://docs.gamesparks.com/api-documentation/rest-apis/requests.html#!/Leaderboards/post_rs_credential_secret_LeaderboardDataRequest), the only question is how can credentials used for this?


I've created a credential as you can see below:

image


Putting together all the above pieces, I would think that a call like

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
  "@class": ".LeaderboardDataRequest",
  "entryCount": 3,
  "leaderboardShortCode": "GAMES_PLAYED_ALL"
}' 'https://<apikey>.preview.gamesparks.net/rs/frontend/<secret>/LeaderboardDataRequest'

 should work.


Unfortunately, it returns an `authentication: NOTAUTHORIZED` error.


Is it possible to make unauthenticated requests using the secret?


Best Answer

I dont think you can do this - but what you CAN do is use an http callback (still requires a secret - but doesn't require player authentication) - it can then make the leaderboard request and then return the data

Implementing External HTTP Callbacks - GameSparks Learn

https://docs.gamesparks.com/tutorials/.../implementing-external-http-callbacks.html

https://docs.gamesparks.com/tutorials/cloud-code-and-the-test-harness/using-custom-callback-urls.html


Answer

I dont think you can do this - but what you CAN do is use an http callback (still requires a secret - but doesn't require player authentication) - it can then make the leaderboard request and then return the data

Implementing External HTTP Callbacks - GameSparks Learn

https://docs.gamesparks.com/tutorials/.../implementing-external-http-callbacks.html

https://docs.gamesparks.com/tutorials/cloud-code-and-the-test-harness/using-custom-callback-urls.html


1 person likes this

Thanks, it works!

Login to post a comment