> ## Documentation Index
> Fetch the complete documentation index at: https://docs.radar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Geo-compliance overview and quickstart

> Run one Radar verified location check end to end, and read the pass or fail result on your backend.

Geo-compliance verifies that a user is in a location where your product is allowed, and that the location can be trusted. By the end of this quickstart, your app will run one verified location check, your backend will verify the returned geolocation token and read `passed`, and you will have seen both a passed and a failed check.

> [!NOTE]
>
> Fraud detection and verified location checks are available on the [Enterprise plan](https://radar.com/pricing).

## Quickstart

Before you start:

* Enable Fraud for your project: under **Fraud** on the [Settings](https://dashboard.radar.com/settings#fraud-settings) page of the Radar dashboard, select **Yes** for **Enabled**. In the same section, allow the state you are testing from in the country and state lists. An empty list allows every country or state.
* Install the Radar SDK and the fraud plugin for your platform. See [Fraud plugin setup](https://docs.radar.com/sdk/fraud.md). The Mac and Windows SDKs are available on request.
* Get a Test publishable key for your app, and your project's JWT secret key for your backend. The JWT secret key is shown in the same **Fraud** section. See [Choose the right API key](https://docs.radar.com/fundamentals/authentication-and-access.md#choose-the-right-api-key).

The client initializes the SDK, sets the signed-in user, requests location permission, runs one check, and sends the token to your backend:

```swift Swift theme={null}
import CoreLocation
import RadarSDK

final class LocationCheck: NSObject, CLLocationManagerDelegate {
  private let locationManager = CLLocationManager()

  func start() {
    Radar.initialize(publishableKey: "prj_test_pk_...")
    Radar.setUserId("user-123")
    Radar.setProduct("sportsbook")

    locationManager.delegate = self
    locationManager.requestWhenInUseAuthorization()
  }

  func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
    let status = manager.authorizationStatus
    if status == .authorizedWhenInUse || status == .authorizedAlways {
      check(reason: "login")
    }
  }

  func check(reason: String) {
    Radar.trackVerified(
      beacons: false,
      desiredAccuracy: .medium,
      reason: reason,
      transactionId: nil
    ) { (status, token) in
      guard status == .success, let token = token, let jwt = token.token else {
        showCheckError(status)
        return
      }

      if token.passed {
        sendTokenToBackend(jwt)
      } else {
        showFailure(token.failureReasons ?? [])
      }
    }
  }
}
```

```kotlin Kotlin theme={null}
import android.Manifest
import android.os.Bundle
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import io.radar.sdk.Radar
import io.radar.sdk.RadarInitializeOptions

class MainActivity : AppCompatActivity() {
  private val requestLocation =
    registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { grants ->
      if (grants.values.any { it }) check("login")
    }

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    Radar.initialize(
      context = this,
      publishableKey = "prj_test_pk_...",
      options = RadarInitializeOptions(fraud = true)
    )
    Radar.setUserId("user-123")
    Radar.setProduct("sportsbook")

    requestLocation.launch(
      arrayOf(
        Manifest.permission.ACCESS_FINE_LOCATION,
        Manifest.permission.ACCESS_COARSE_LOCATION
      )
    )
  }

  private fun check(reason: String) {
    Radar.trackVerified(reason = reason) { status, token ->
      if (status != Radar.RadarStatus.SUCCESS || token == null) {
        showCheckError(status)
        return@trackVerified
      }

      if (token.passed) {
        sendTokenToBackend(token.token)
      } else {
        showFailure(token.failureReasons)
      }
    }
  }
}
```

```javascript JavaScript theme={null}
import Radar from 'radar-sdk-js';
import { createFraudPlugin } from '@radarlabs/plugin-fraud';

Radar.registerPlugin(createFraudPlugin());
Radar.initialize('prj_test_pk_...');
Radar.setUserId('user-123');
Radar.setProduct('sportsbook');

// false uses the Radar Verify app. true verifies in the browser without it.
const skipVerifyApp = false;

async function check(reason) {
  try {
    const result = await Radar.fraud.trackVerified({ skipVerifyApp, reason });

    if (result.passed) {
      await sendTokenToBackend(result.token);
    } else {
      showFailure(result.failureReasons);
    }
  } catch (err) {
    if (err instanceof Radar.fraud.errors.RadarVerifyAppError) {
      promptToOpenVerifyApp();
    } else {
      showCheckError(err.status);
    }
  }
}

check('login');
```

```javascript React Native theme={null}
import Radar from 'react-native-radar';

Radar.initialize('prj_test_pk_...', true);
Radar.setUserId('user-123');
Radar.setProduct('sportsbook');

async function check(reason) {
  const permission = await Radar.requestPermissions(false);
  if (permission !== 'GRANTED_FOREGROUND' && permission !== 'GRANTED_BACKGROUND') {
    showPermissionNeeded();
    return;
  }

  try {
    const { token } = await Radar.trackVerified({ reason });

    if (token?.passed) {
      await sendTokenToBackend(token.token);
    } else {
      showFailure();
    }
  } catch (err) {
    showCheckError(err);
  }
}

check('login');
```

```swift macOS theme={null}
import RadarVerifySDK

// Call once at launch. Requests location permission and warms up location services.
func start() {
  RadarVerify.setup()
}

func check(reason: String) async {
  let result = await RadarVerify.trackVerified(
    publishableKey: "prj_test_pk_...",
    userId: "user-123",
    product: "sportsbook",
    reason: reason
  )

  guard result.status == .success, let token = result.token else {
    showCheckError(result.status)
    return
  }

  if token.passed {
    sendTokenToBackend(token.token)
  } else {
    showFailure(token.failureReasons)
  }
}
```

```csharp Windows theme={null}
using System.Threading.Tasks;
using RadarVerify;

public static class LocationCheck
{
    // Call once at startup. Checks location permission and warms up location services.
    public static Task<RadarStatus> Start() => Radar.Setup();

    public static async Task Check(string reason)
    {
        var (status, token) = await Radar.TrackVerified(
            publishableKey: "prj_test_pk_...",
            userId: "user-123",
            product: "sportsbook",
            reason: reason);

        if (status != RadarStatus.Success || token == null)
        {
            ShowCheckError(status);
            return;
        }

        if (token.Passed)
        {
            await SendTokenToBackend(token.Token);
        }
        else
        {
            ShowFailure(token.FailureReasons);
        }
    }
}
```

The backend verifies the token and reads `passed`:

```javascript Node.js theme={null}
import express from 'express';
import { jwtVerify } from 'jose';
import { requireSession } from './auth.js';

const secret = new TextEncoder().encode(process.env.RADAR_JWT_SECRET_KEY);
const app = express();
app.use(express.json());

app.post('/api/wagers', requireSession, async (req, res) => {
  let payload;
  try {
    ({ payload } = await jwtVerify(req.body.geolocationToken, secret, {
      algorithms: ['HS256'],
    }));
  } catch (err) {
    return res.status(401).json({ error: 'invalid_geolocation_token' });
  }

  if (payload.user?.userId !== req.session.userId || payload.product !== 'sportsbook') {
    return res.status(401).json({ error: 'invalid_geolocation_token' });
  }

  if (payload.passed !== true) {
    return res.status(403).json({ passed: false, failureReasons: payload.failureReasons });
  }

  // Place the wager.
  res.status(201).json({ placed: true });
});
```

```python Python theme={null}
import os

import jwt  # PyJWT
from flask import Flask, jsonify, request, session

app = Flask(__name__)
app.secret_key = os.environ["SESSION_SECRET_KEY"]
SECRET = os.environ["RADAR_JWT_SECRET_KEY"]


@app.post("/api/wagers")
def place_wager():
    if "user_id" not in session:
        return jsonify(error="not_signed_in"), 401

    body = request.get_json(silent=True) or {}
    try:
        payload = jwt.decode(body.get("geolocationToken", ""), SECRET, algorithms=["HS256"])
    except jwt.InvalidTokenError:
        return jsonify(error="invalid_geolocation_token"), 401

    user_id = (payload.get("user") or {}).get("userId")
    if user_id != session["user_id"] or payload.get("product") != "sportsbook":
        return jsonify(error="invalid_geolocation_token"), 401

    if payload.get("passed") is not True:
        return jsonify(passed=False, failureReasons=payload.get("failureReasons", [])), 403

    # Place the wager.
    return jsonify(placed=True), 201
```

Your backend decides, not your app. The `passed` value on the client is for your UI. For every validation step, see [Validate a token](https://docs.radar.com/api/geolocation-tokens.md#validate-a-token).

## See a passed and a failed result

Sign in as `user-123` from an allowed state and trigger the action. After signature verification, the payload includes these fields, and your backend performs the action:

```json theme={null}
{
  "passed": true,
  "failureReasons": [],
  "product": "sportsbook",
  "reason": "login",
  "user": {
    "userId": "user-123",
    "state": { "code": "NJ", "allowed": true, "passed": true },
    "fraud": { "passed": true, "verified": true }
  }
}
```

To see a failed result without changing location, create a rule on the **Block rules** page in the dashboard that blocks the user ID `user-123`, then trigger the action again. The request succeeds, the token carries a failed result, and your backend rejects the action:

```json theme={null}
{
  "passed": false,
  "failureReasons": ["fraud_blocked_user_id"],
  "product": "sportsbook",
  "reason": "login",
  "user": {
    "userId": "user-123",
    "state": { "code": "NJ", "allowed": true, "passed": true },
    "fraud": { "passed": false, "verified": true, "blocked": true }
  }
}
```

Remove the block rule when you finish. See [Force a pass or a fail](https://docs.radar.com/fundamentals/testing-and-launch.md#force-a-pass-or-a-fail), and for the full payload, [Geolocation token schema](https://docs.radar.com/api/geolocation-tokens.md).

## Understand check results

A check produces four separate facts. They aren't interchangeable:

* **The request succeeded**: The client returned a success status and a token. The token can still carry `passed` set to `false`.
* **The token is authentic**: Your backend verified the signature and expiry with your JWT secret key. That doesn't say the token belongs to this user, product, or action.
* **The location was verified**: `passed` is `true` in the verified payload, so the jurisdiction and fraud checks passed.
* **The user is eligible**: The token is authentic, belongs to the signed-in user and the intended product, hasn't expired, and has `passed` set to `true`.

Perform a protected action only when the last statement holds.

## Next steps

For products, when to run checks, the companion app, and desktop apps, see [Verify location for compliance](https://docs.radar.com/geo-compliance/verify-location.md).

To assess device and network risk without a location requirement, start with [Fraud overview and quickstart](https://docs.radar.com/fraud/overview.md) instead.

## See also

* [Verify location for compliance](https://docs.radar.com/geo-compliance/verify-location.md): the full implementation guide.
* [Geolocation token schema](https://docs.radar.com/api/geolocation-tokens.md): token validation, every field, [failure and warning reasons](https://docs.radar.com/api/geolocation-tokens.md#failure-and-warning-reasons), and [expiry](https://docs.radar.com/api/geolocation-tokens.md#expiry).
* [Fraud plugin setup](https://docs.radar.com/sdk/fraud.md): install and initialize the fraud plugin on each platform.
* [Understand foreground and background location permissions](https://docs.radar.com/fundamentals/location-permissions.md)
* [Test, troubleshoot, and go live](https://docs.radar.com/fundamentals/testing-and-launch.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.