NadeoServices plugin dependency
The NadeoServices
plugin provides an easy interface into Trackmania's online services authentication.
NadeoServices outside of Openplanet
If you're looking to access the NadeoServices outside of Openplanet, we have a complete unofficial documentation here, that contains information about authenticating with Nadeo's API externally.
Why use NadeoServices?
It is important to depend on the NadeoServices
plugin if you intend to communicate with Nadeo's API in plugins! This is because authentication tokens aren't easy to reliably get in scripts, and multiple plugins trying to access the same token can cause the game to start behaving bad. The NadeoServices
plugin takes care of cleanly accessing authentication tokens from the game and creating HTTP requests plugins.
Audiences
Nadeo's API has several types of tokens with different audiences. The following audiences exist:
NadeoLiveServices
- Live and Meet APINadeoServices
- Core API
Getting started
To get started with the NadeoServices
plugin, add a dependency to it in your info.toml
:
[script]
dependencies = [ "NadeoServices" ]
API
The API consists out of the following functions:
NadeoServices::AddAudience
Tells the NadeoServices
plugin that you'd like to use a specific audience.
Parameters:
const string &in audience
The audience you want to use.
NadeoServices::IsAuthenticated
Checks if the given audience is authenticated. You can only start making requests once the audience has been authenticated.
Parameters:
const string &in audience
The audience you want to check.
Returns: bool
NadeoServices::GetAccountID
Gets the current user's account ID.
Returns: string
NadeoServices::BaseURLCore
Returns the base URL for the core API. (Requires the NadeoServices
audience)
Returns: string
NadeoServices::BaseURLLive
Returns the base URL for the live API. (Requires the NadeoLiveServices
audience)
Returns: string
NadeoServices::BaseURLMeet
Returns the base URL for the meet API. (Requires the NadeoLiveServices
audience)
Returns: string
NadeoServices::Request
Create an HTTP request object with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.
Parameters:
const string &in audience
The audience you want to use.
Returns: Net::HttpRequest@
NadeoServices::Get
Creates a GET
HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.
Parameters:
const string &in audience
The audience you want to use.const string &in url = ""
The complete URL to request.
Returns: Net::HttpRequest@
NadeoServices::Post
Creates a POST
HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.
Parameters:
const string &in audience
The audience you want to use.const string &in url = ""
The complete URL to request.const string &in body = ""
The body of the POST request.const string &in contentType = "application/json"
The content type header to send.
Returns: Net::HttpRequest@
NadeoServices::Put
Creates a PUT
HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.
Parameters:
const string &in audience
The audience you want to use.const string &in url = ""
The complete URL to request.const string &in body = ""
The body of the POST request.const string &in contentType = "application/json"
The content type header to send.
Returns: Net::HttpRequest@
NadeoServices::Delete
Creates a DELETE
HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.
Parameters:
const string &in audience
The audience you want to use.const string &in url = ""
The complete URL to request.
Returns: Net::HttpRequest@
NadeoServices::Patch
Creates a PATCH
HTTP request with the correct authentication header for the audience already filled in. Throws an exception if the audience is not authenticated yet.
Parameters:
const string &in audience
The audience you want to use.const string &in url = ""
The complete URL to request.const string &in body = ""
The body of the POST request.const string &in contentType = "application/json"
The content type header to send.
Returns: Net::HttpRequest@
NadeoServices::GetDisplayNameAsync
Gets a display name from an account ID. Must be called from a yieldable function. Does not require any audience. If you want to fetch multiple display names, use NadeoServices::GetDisplayNamesAsync
instead, as it will be much more efficient.
Parameters:
const string &in accountId
The account ID to get the display name for.
Returns: string
NadeoServices::GetDisplayNamesAsync
Gets multiple display names (as string
) from their account IDs. Must be called from a yieldable function. Does not require any audience. If you want to fetch only a single display name you can also use GetDisplayNameAsync
.
Parameters:
const array<string> &in accountIds
The account IDs to get display names for.
Returns: dictionary