How to Get a Cesium ION Token for God's Eye View: Complete Setup Guide
To get a Cesium ION token for God's Eye View, generate an access token from cesium.com/ion, add it to a .env file as VITE_CESIUM_ION_TOKEN, and the application's src/main.js will automatically inject it into Cesium.Ion.defaultAccessToken before the Viewer initializes in src/mapStartup.js.
God's Eye View is a 3D geospatial visualization application built with CesiumJS and Vite. The bilawalsidhu/gods-eye-view repository requires a valid Cesium ION access token to render base imagery and terrain data, which the codebase expects to receive via build-time environment variables.
Obtaining a Cesium ION Access Token
Before configuring the application, you must acquire a token from the Cesium cloud platform:
- Navigate to cesium.com/ion and sign in or create a free account.
- Select Access Tokens from the left sidebar navigation.
- Choose the Default token or create a new token with read access to Cesium World Imagery.
- Copy the token string (it begins with
eyJ).
Store this token securely. You will inject it into the God's Eye View build environment using the steps below.
Configuring the Cesium ION Token in God's Eye View
The repository follows the standard Vite pattern for securing API credentials. The vite.config.js file automatically exposes any environment variable prefixed with VITE_ to the client bundle at compile time.
Setting Up the Environment File
Create a file named .env in the project root directory and add your token:
VITE_CESIUM_ION_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Vite embeds this value during both development (npm run dev) and production builds (npm run build). Never commit this file to Git; add .env to your .gitignore immediately to prevent exposing your credentials.
How src/main.js Injects the Token
According to the source code, the application assigns the token to the Cesium global object immediately upon startup. In src/main.js, the logic reads:
import * as Cesium from "cesium";
// Set the default Cesium ion token from the build-time env var
const ionToken = import.meta.env.VITE_CESIUM_ION_TOKEN;
if (!ionToken) {
console.warn("[Gods Eye View] No Cesium ion token found – the default basemap may not load.");
}
Cesium.Ion.defaultAccessToken = ionToken;
This assignment must execute before any new Cesium.Viewer() call. The code validates the token's existence and logs a specific console warning if import.meta.env.VITE_CESIUM_ION_TOKEN is undefined, preventing silent authentication failures.
Viewer Initialization in src/mapStartup.js
The actual Viewer instantiation occurs in src/mapStartup.js within the createViewer function. Because src/main.js runs first and sets Cesium.Ion.defaultAccessToken, the Viewer requires no additional token parameters:
// src/mapStartup.js
import * as Cesium from "cesium";
export function createViewer(container) {
// Cesium.Ion.defaultAccessToken is already set by main.js
return new Cesium.Viewer(container, {
terrainProvider: Cesium.createWorldTerrain()
});
}
The Viewer automatically inherits the global token configuration, allowing it to fetch Cesium World Terrain and imagery assets without further authentication logic.
Runtime Token Injection Alternative
If environment variables are unavailable, you can pass the token via URL query parameters. The repository supports reading cesiumIonToken from window.location.search as a fallback:
// Add to src/main.js or src/mapStartup.js before Viewer creation
if (!Cesium.Ion.defaultAccessToken) {
const urlToken = new URLSearchParams(window.location.search).get("cesiumIonToken");
if (urlToken) {
Cesium.Ion.defaultAccessToken = urlToken;
}
}
Access the application using:
https://your-domain.com?cesiumIonToken=eyJhbG...
This method is useful for sharing demonstration builds without distributing a static .env file.
Summary
- Generate a Cesium ION access token from cesium.com/ion with default asset permissions.
- Configure the
.envfile in the project root withVITE_CESIUM_ION_TOKEN=your_token. - Verify that
src/main.jsassigns the token toCesium.Ion.defaultAccessTokenviaimport.meta.env.VITE_CESIUM_ION_TOKEN. - Confirm that
src/mapStartup.jscallsnew Cesium.Viewer()only after the token is set globally. - Optionally use URL parameters (
?cesiumIonToken=...) for dynamic runtime configuration without rebuilding.
Frequently Asked Questions
How do I know if my Cesium ION token is working in God's Eye View?
If the token is valid, the Cesium Viewer will render the default Bing Maps imagery or Cesium World Terrain without console errors. Check the browser's developer tools for the specific warning [Gods Eye View] No Cesium ion token found. If this message is absent and api.cesium.com requests return HTTP 200, your token is functioning correctly.
Can I use a default Cesium token instead of creating my own?
CesiumJS provides a default evaluation token, but it is rate-limited and strictly intended for development purposes. For production deployments of God's Eye View, you must generate a personal access token from your Cesium ion account to ensure reliable service and compliance with usage quotas.
Is it safe to commit my .env file with the Cesium ION token to Git?
No. Exposing VITE_CESIUM_ION_TOKEN in version control creates a security vulnerability. Always add .env to .gitignore. If accidentally committed, revoke the token immediately in your Cesium ion dashboard under Access Tokens and generate a replacement to prevent unauthorized asset consumption.
Why does the Cesium Viewer in God's Eye View show a blank globe without errors?
A blank or black globe typically indicates the Viewer initialized but failed to retrieve imagery due to an invalid or missing token. Verify that import.meta.env.VITE_CESIUM_ION_TOKEN is not undefined in src/main.js and that the assignment to Cesium.Ion.defaultAccessToken occurs before the createViewer() function executes in src/mapStartup.js.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →