HTTP Examples#

This page provides practical examples of how to use the EarthScope CLI to retrieve your access token for use within common HTTP command line tools like cURL and Wget.

File Server Access Examples#

Your access token can be used to retrieve files from EarthScope’s Data File Server.

Prerequisites#

  1. Login: This step is only required once (the first time you run the CLI on your device) unless your access token is deleted from your device.

    es login
    
  2. Get Access Token: Retrieve your token using es user get-access-token. Add this access token as an Authorization header with your cURL or Wget command.

Using cURL#

curl -L -O -f --url https://data.earthscope.org/archive/gnss/rinex/obs/1992/001/algo0010.92d.Z --header "authorization: Bearer $(es user get-access-token)"

cURL Options Explained:

  • -L: Follow redirects

  • -O: Use server filename

  • -f: (HTTP) Fail on error without server output. Error code 22 — good for scripting

Warning

Make sure to include the -f flag or it may be difficult to tell if an error occurred.

Using Wget#

wget https://data.earthscope.org/archive/gnss/rinex/obs/2022/060/p1230600.22d.Z --header "authorization: Bearer $(es user get-access-token)"

Additional Resources#

For more file server access examples, see the GAGE Facility’s GPS/GNSS file server access examples.

API Integration Examples#

Scripting with Access Tokens#

When writing scripts that need to access EarthScope resources, use the CLI commands to retrieve access tokens rather than hardcoding them:

#!/bin/bash
# Good practice: Use CLI to get fresh token
TOKEN=$(es user get-access-token)
curl -H "Authorization: Bearer $TOKEN" \
     "https://api.earthscope.org/beta/user/profile"

Warning

Never hard-code your access token into scripts. Access tokens expire after 24 hours and cannot be used afterwards unless refreshed. Using the CLI commands ensures you always have a valid token.