Front End
Integration
To get the game up and running you will need to insert this snippet on the page where you want the game platform to be loaded:
<div class="scout-games-wrapper">
<view-port></view-port>
</div>
<script
src="https://customer-static.api.scoutgg-stg.net/application.js"
data-white-label="customer"
></script>
<div class="scout-games-wrapper">
<view-port></view-port>
</div>
<script
src="https://customer-static.api.scoutgg.net/application.js"
data-white-label="customer"
></script>
This will bootstrap the Scout Gaming Platform and it will render inside the view-port HTML tag. The dataset can be used to override default configurations.
For instance if you need to change the language to Spanish, you can override the config option by setting data-lang="es".
Configuration options
| Config Parameter | Data parameter(script tag) | Options | Default | Comment |
|---|---|---|---|---|
| currency | data-currency | Any ISO 4217 supported code | EUR | |
| whiteLabel | data-white-label | customer | none | Is required. Will be provided to you by your Key Account Manager (KAM). |
| token | data-token | none | none | Token should be generated when a user is logged in and passed to this parameter. If a token is present the platform will assume a user is logged in. If a token isn't ready during script initialization it can be set via window.ftWidgets.config.token = token |
| basePath | data-base-path | none | / | Should be the base path to the game. For instance /sports/fantasy/. Base path should always have a trailing slash. |
| lang | data-lang |
|
en - English | If you want language to be reflected from your own language selector, use window.ftWidgets.config.lang = value |
| none | data-platform |
|
v1 | Set to v2 to load the V2 platform through the same application.js. An https URL on a Scout Gaming host (scoutgg.net, scoutgg-stg.net) also loads V2, from that host. An empty value or any other value loads the current platform. See V2 platform. |
Scout Widgets API
The Widgets API is a way to change configuration parameters after the script has bootstrapped. After bootstrapping window.ftWidgets will be available. ftWidgets contains a few helper functions, including the config scheme.
// Accessible in the browser after Scout Gaming
// platform has bootstrapped
{
"page": Function, // Access to the Scout UI Router
"renderSite": Function, // Trigger a repaint of all visible components
"config": Object, // Access all configuration parameters
"models": Object // Access to all models used,
"startApp": Function // Force fantasy app to re-initialize for integration with your spa router or handling browser history navigation
}
You can change the configuration options on the fly. Example:
// Guard the API (check that its bootstrapped)
if (window.ftWidgets) {
window.ftWidgets.config.lang = "es";
window.ftWidgets.config.token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30"
}
SPA Integration example
const script = document.createElement('script')
script.src = `https://customer-static.api.scoutgg.net/application.js`
script.setAttribute('data-white-label', 'customer')
script.setAttribute('data-base-path', `/fantasy/`) //basepath where fantasy app will be started at your navigation e.g /fantasy/
document.body.appendChild(script)
// Wait for script to load, then ensure app is started
script.onload = () => {
// Call startApp to initialize the app
if(window.ftWidgets) {
window.ftWidgets.startApp()
}
}
Integration with React example
function FantasyApp({ token }) {
useEffect(() => {
const script = document.createElement('script')
script.src = `https://customer-static.api.scoutgg.net/application.js`
script.setAttribute('data-white-label', 'customer')
script.setAttribute('data-token', token) //initial token if exist
script.setAttribute('data-base-path', `/fantasy/`) //basepath where fantasy app will be started at your navigation e.g /fantasy/
document.body.appendChild(script)
// Wait for script to load, then ensure app is started
script.onload = () => {
// Call startApp to initialize the app
if(window.ftWidgets) {
window.ftWidgets.startApp()
}
}
}, []) //run once
useEffect(() => {
if (window.ftWidgets) {
window.ftWidgets.config.token = token
}
}, [token]) //update auth token when changed
return (
<div>
<h1>Fantasy Page</h1>
<div className="scout-games-wrapper">
{/* //viewport required */}
<view-port></view-port>
</div>
</div>
)
}
V2 platform
V2 is the new version of the game. It is loaded by the same application.js you already use: there is no separate V2 script and no new URL. V2 reads the same data-* options and offers the same window.ftWidgets API described above, so a page built for the current platform runs V2 without other changes. The game renders in an iframe that the script places inside your view-port.
Your Key Account Manager (KAM) will tell you when V2 is available for customer.
Switching to V2
Keep the script tag you already have and add data-platform="v2" to it. The src stays the same:
<div class="scout-games-wrapper">
<view-port></view-port>
</div>
<script
src="https://customer-static.api.scoutgg-stg.net/application.js"
data-white-label="customer"
data-platform="v2"
></script>
<div class="scout-games-wrapper">
<view-port></view-port>
</div>
<script
src="https://customer-static.api.scoutgg.net/application.js"
data-white-label="customer"
data-platform="v2"
></script>
| data-platform | What loads |
|---|---|
| v2 | The V2 platform |
An https URL on a Scout Gaming host, for example https://customer-v2.api.scoutgg-stg.net |
The V2 platform from that host |
| v1, empty, any other value, or not set | The current platform |
Content Security Policy
With data-platform="v2", application.js loads a second script, application.js from the V2 host, and the game iframe comes from that same host. If your page sends a Content Security Policy, allow the V2 host in script-src and frame-src, next to the -static host you already allow:
script-src https://customer-static.api.scoutgg-stg.net https://customer-v2.api.scoutgg-stg.net;
frame-src https://customer-v2.api.scoutgg-stg.net;
script-src https://customer-static.api.scoutgg.net https://customer-v2.api.scoutgg.net;
frame-src https://customer-v2.api.scoutgg.net;
The V2 script makes no other requests from your page; the game talks to its servers from inside the iframe.
Trying V2 in your browser
To try V2 on your page without changing the script tag, run this in the browser console and reload the page:
localStorage.platformVersion = "v2" // load V2
localStorage.platformVersion = "v1" // load the current platform
localStorage.removeItem("platformVersion") // follow the script tag again
The setting applies only to that browser.
What changes in V2
| Topic | V2 behaviour |
|---|---|
| Rendering | The game runs in an iframe inside your view-port. By default the iframe fills the visible window (at least 480px high). Add data-height="auto" to the script tag to let the iframe grow with its content instead, so your page scrolls rather than the game. |
| Sign in | When a signed-out player tries to join a game, window receives a sggAuthenticationRequired event. event.detail.redirectUrl is the game screen the player was on. Show your login, then set window.ftWidgets.config.token. |
| Expired token | Set window.ftWidgets.config.refreshToken to a function that returns a new token (or a promise of one). V2 calls it when the token is refused, at most once every 30 seconds, and uses the token it returns. |
| Opening a screen | window.ftWidgets.page(path) opens a V2 screen, for example "/" (lobby), "/my-entries" or "/draft-and-go". |
| Configuration | token, lang and currency can be changed at any time and are passed to the game at once. whiteLabel and basePath are read-only. |
| API | startApp() mounts the game again (call it after your SPA router re-renders the page), destroyApp() removes the game and its script tag, renderSite() asks the game to repaint. models is an empty object in V2. |
| Accounts and payments | Login, registration, deposits and withdrawals stay on your site. The game shows no login or cashier of its own. |
V2 example
// After application.js has loaded
window.addEventListener("sggAuthenticationRequired", (event) => {
openYourLogin({ returnTo: event.detail.redirectUrl })
})
window.ftWidgets.config.refreshToken = async () => {
const res = await fetch("/api/scout-token") // your endpoint that signs a new JWT
return res.text()
}
// After your login succeeds
window.ftWidgets.config.token = newToken
The token is the same JWT as on the current platform; see Authentication below.
Authentication
Authentication is done by passing a JWT Token to the token config parameter. A secret to sign the JWT token will be provided to you by your Key Account Manager (KAM). For more information on JWT you can see jwt.io. Generating the token must happen server side to not expose the secret in the frontend. The token should include the following payload:
{
id: String, // The unique identifier of your user
username: String, // A username that is displayed in the game
exp: Number, // Expiry of the token. Unix timestamp (seconds).
iat: Number, // Issued at. Timestamp of when the token was generated.
}
Node.js Express example of generating token.
const jwt = require("jsonwebtoken");
const config = require("../config");
const db = require("../services/database-connection");
module.exports = async function getToken(req, res) {
const user = await db.query("SELECT * FROM users WHERE id = $1", [req.user.id]);
const now = Math.floor(Date.now() / 1000); // Unix timestamp
const payload = {
id: String(user.id),
username: user.username,
exp: now + 60 * 60,
iat: now,
};
const token = jwt.sign(payload, config.secret);
res.send(token);
};
Examples for other stacks — Python (Flask/FastAPI), PHP, .NET (C#), Java and Kotlin — are available in Authentication → Implementation Examples.