The server-to-server (S2S) Rest APIs provide a secure channel to interact with Meta Horizon platform. For example, you might want to update an Meta leaderboard after you host a multi-player match on your server. This topic provides details about the leaderboard-related server calls that you can make.
Message Basics
There are some server to server message basics you should be familiar with.
Server-to-Server API requirements
Calls to these APIs must meet the following requirements:
Endpoint
Make all server-to-server requests to this endpoint:
https://graph.oculus.com
Access token
Include an access token with every request to authenticate it either as a valid server request or on behalf of a specific user. The access token can be one of the following:
App credentials authenticate your server’s back-end as a trusted resource. Never share these credentials with any client-side application.
The access token with app credentials includes the App ID and App Secret from the API page on the Meta Horizon Developer Dashboard. It follows this format: OC|$APPID|$APPSECRET.
If your credentials are compromised or you need new API credentials, generate a new app secret. Changing the app secret will revoke the permissions of the previous one. Accessing the app secret requires an administrator account.
User access token
A user access token authenticates requests on behalf of a user. Use this token type when actions relate to a specific user. An example case is updating a client-authoritative leaderboard with the results of a server-hosted multiplayer match. For each user, you would use the user access token to authenticate your server as you make requests to update their leaderboards.
Retrieve the user token with the ovr_User_GetAccessToken() method.
Alternatively, use the following blueprint function:
The token will be returned as a response and can be passed from the client to your server.A user access token contains FRL or OC and a long alpha numeric string similar to the following: FRL12342GhFccWvUBxPMR4KXzM5s2ZCMp0mlWGq0ZBrOMXyjh4EmuAPvaXiMCAMV9okNm9DXdUA2EWNplrQ.
Additionally, you can retrieve your user token for testing purposes at the ‘User Token’ section of the API page of the Meta Horizon Developer Dashboard, which is at the left navigation bar.
App ID
Some server calls require an app ID, which you can find on the API page of the Meta Horizon Developer Dashboard.
Note: The cURL examples demonstrate calls with the Windows command line. Other platforms may vary.
Create or Update a Leaderboard
Use this method to create a leaderboard, or update the properties of an existing one. You can use this method to specify or update localized display titles for the leaderboard. See the title_locale_map parameter for more details.
Note: Leaderboard metadata can be retrieved by anyone. Avoid storing sensitive information when creating or updating leaderboards.
The response contains a status, did_update indicates whether the entry was recorded or not. Entries will not be recorded if the user already has an entry on the leaderboard, the new score is worse than the old score, and force_update is false.
You can retrieve leaderboard entries for users including the user ID, alias and profile URL, as well as the leaderboard rank, entry count, and more. When you call this method, you should:
Authenticate the call with the user token if the start_at param is one of the VIEWER options.
Authenticate the call with the user token if the filter param is FRIENDS.
Otherwise, authenticate the call with the app token.
Delete a leaderboard. The leaderboard-id is the ID returned from the Create or Update a Leaderboard request.
Once deleted, a leaderboard entry cannot be recovered.
What if you follow the curl request example, but the REST API does not work?
First, you want to double check if the access_token has been set correctly. In some requests it’s OC|$APP_ID|$APP_SECRET while
in some requests it’s user access token.
If you use the curl command to hit the API, please make sure you use backslash to escape characters like double quote and square bracket.
If your curl command contains data field like offset or allowed time stamps, you need to make sure the values set aligned with your query.
Otherwise, the result will not be returned.