Skip to main content
By the end of this guide, your app will run a verified location check for the signed-in user and the selected product, and your backend will perform a restricted action, such as a wager, a contest entry, or a withdrawal, only when the geolocation token it verified has passed set to true. Sportsbooks, casinos, fantasy, sweepstakes, and predictions generally follow the same implementation pattern: configure allowed locations, run a check, validate the token on your backend, and act on passed. How often you check and re-check can differ by product and market.

Complete example

This is the whole client side of one check on each platform.
The backend verifies the token and reads passed:

Prerequisites

Configure allowed locations

Allowed countries and states are set in the Fraud section of the Settings page, once for the project and once for each product. Each list is an allowlist or a blocklist, and an empty list allows every country or state. A product setting overrides the project setting with the same name. Changes apply to checks made after you save, and tokens already issued keep their result until they expire.

Choose manual or automatic checks

Call Radar.setUserId() with the ID your backend uses for the signed-in user, so that your backend can compare the token to the session. See Handle login, logout, and user switching. There are two ways to run checks. Backend validation is the same for both. The rest of this guide uses manual checks, as the complete example does. Choose automatic checks when you want a valid token ready for the whole session without scheduling checks yourself. You can combine the two: run automatic checks for the session, and call Radar.trackVerified() with a reason and a transactionId before a single-use action, such as a withdrawal.

Run automatic checks

Start automatic checks at login, after the user grants location permission, and stop them at logout. The SDK passes the token from each check to a listener, so that your app can send it to your backend. sendTokenToBackend is a function you write.
On web, automatic checks respond to IP address changes only when you pass ipChanges: true, and they use the companion app unless you pass skipVerifyApp: true. See Choose the companion app or the no-download path. For every option, see Manual and automatic checks and the verified location section of the iOS or Android SDK reference.

Validate the response on the backend

Your backend decides, not your app. The passed value your app reads is for your UI. The backend block in the complete example is the minimum: verify the HS256 signature and expiry with your project’s JWT secret key, compare user.userId to the session user and product to the product of the action, then read passed. In production, also require user.live to be true, so that a Test environment token isn’t accepted.
Always verify the token on your backend before a restricted action. Don’t rely on a passed value from the client, and keep the JWT secret key out of client code.
For every validation step, see Validate a token. If your project uses encrypted responses, decrypt the token before you verify it.

Select the product

A product is a named configuration inside a project, such as sportsbook, casino, or fantasy, with its own allowed countries and states. You configure products in the Fraud section of the Settings page. Call Radar.setProduct() before the check with the product the user is using. passed in the token is the result for that product, so when the user switches product, set the new product and run a new check. If you have one offering with one set of allowed locations, you don’t need products. Leave out Radar.setProduct(). To narrow a check to the jurisdiction of the user’s session, call Radar.setExpectedJurisdiction() with a country code and a state code before the check (Radar.fraud.setExpectedJurisdiction() on web).

Run checks at the right time

With manual checks, your app decides when each check runs. With automatic checks, the SDK handles expiry and IP changes, and you clear the token when the user changes product. Run the first check at login, before you show restricted features. After that, reuse the token until one of these happens:
  • The token expires. Each token carries its own expiry in expiresAt, and tokens issued close to a border expire sooner. Compare the current time to expiresAt before each restricted action. Don’t hardcode an interval. See Expiry.
  • The user changes product. Call Radar.setProduct() with the new product, then run a check.
  • The SDK reports an IP change. Implement didChangeIP() on your RadarVerifiedDelegate on iOS, override onIpChanged() on your RadarVerifiedReceiver on Android, or register a callback with Radar.fraud.onIpChanged() on web. In the callback, discard the last token and run a check.
Run one check at a time. For a single-use action, such as a withdrawal, generate a transactionId on your backend, pass it to the check, and compare it to transactionId in the verified token. Pass a reason on every check, such as login, wager, or withdrawal. Radar returns it in the token as reason, so use a small fixed set of values.

Choose the companion app or the no-download path

On web, a check runs one of two ways. Choose the path for your product and market with your legal and compliance team:
  • Radar Verify companion app: The user installs it once, and each check runs through the app.
  • No-download path: The check runs in the browser and the user installs nothing.
Pass skipVerifyApp to Radar.fraud.trackVerified(), Radar.fraud.startTrackingVerified(), and Radar.fraud.getVerifiedLocationToken(). Use the same value in all three. With the companion app, tell the user to open or install Radar Verify when a check fails with ERROR_VERIFY_APP, then run the check again.

Verify from a native desktop app

If your product is a native macOS or Windows app instead of a web page, the app runs the check itself with the Mac or Windows SDK, with no companion app. See the macOS and Windows tabs of the complete example. The Mac and Windows SDKs are available on request. See Desktop apps.

Handle results and errors

A failed check is a token with passed set to false. An error is a status other than success, with no token. For every reason and status, see Failure and warning reasons and Handle a technical error.

Test the integration

Use the Test environment and a named test user.
  • Passing case: Sign in as the test user from an allowed state. Confirm that the token has passed set to true and that your backend performs the action.
  • Failing case: On the Block rules page, create a rule that blocks the test user ID, then run a new check. Confirm that the token has passed set to false with fraud_blocked_user_id, and that your backend rejects the action. Remove the rule when you finish.
Bypass rules are for internal testing only. See Force a pass or a fail.

Production checklist

  • Each product’s country and state lists match your written list, and no list that is meant to restrict is empty.
  • Radar.setUserId() and Radar.setProduct() are set before every check, and a product change triggers a new check.
  • A token is reused only until its returned expiry, and one check runs at a time.
  • Every restricted endpoint verifies the token’s signature, expiry, user, product, and user.live, then reads passed. None reads a client-supplied passed.
  • No JWT secret key in any client, and no bypass rule or test block rule in the Live environment.

Build with an agent

Copy this prompt into a coding agent that has access to your repository.

See also