Sign In Register

How can we help you today?

Start a new topic

JavaScript SDK trouble getting connected

Hello Forums,

I've been asked to build a simple leaderboard to display on the game's webpage. Unfortunately our webhost doesn't provide any server-side scripting options so we need to do all the work in the client-side browser. As such we've opted to create an API secret with extremely limited access.

I'm trying to build a proof of concept (connect, get leaderboard data, display HTML table) but I'm running into a lot of problems and confusion. I tried following the examples in the JavaScript SDK but it isn't clear to me what data is expected in which fields. Their example also says onNonce is optional, but the service fails immediately if it's not defined.

By mostly copy/pasting their example my console is full of authorization errors which never stop. Looking at the included "gamesparks.html" example file, it sets properties not mentioned in the SDK tutorial docs, and I can't find expected value examples in documentation. I threw the API shortcode into the "credential" property and stopped getting endless authorization errors, but I still can't connect and get data.

Are there any more complete examples or documentation available? Is there a better/preferred method of getting leaderboard data when we can't secure any code behind server processes? If not, can anyone shed some light on the following questions?

  1. What information is required for each of the init and data request functions? Where would I look for those specific values? Particularly what are the correct data for "key, secret, and credential" in the init function options object, and is the secret used in the nonce function the same secret as the init function?
  2. What settings are required on when setting up an API credential for use with unauthenticated REST requests?
  3. The documentation says the onNonce function is optional, but when it's not included I get "Cannot read property 'enc' of undefined" on the init request. Is the nonce function actually a required property?

Login to post a comment