Authentication

Most requests to the NRAO ODS API must be authenticated. This API supports token-based authentication.

  1. Contact an NRAO ODS Admin to generate a client for you with appropriate scopes. Coordinate the cadence at which your token will expire with NRAO.

  1. Post your client id and client secret as form data to the NRAO ODS API to get your authentication token.

curl -X 'POST' \
  'https://ods.nrao.edu/token/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>'

Response 200 OK

{
  "token": "EXAMPLE_TOKEN"
}
  1. Include the token in the Authorization header to authenticate subsequent NRAO ODS API requests.

curl -X 'GET' \
  'https://ods.nrao.edu/ods_data/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <EXAMPLE_TOKEN>'

4. When your token expires, you will need to repeat Step 2 using the same client_id and client_secret to get a new token. Your client_id and client_secret do not change; you’ll only need to refresh the token itself.

  • Option 1: Proactive refresh. Keep track of when you first requested your token and refresh it before it expires.

  • Option 2: Reactive refresh (demonstrated in `Example Python Script`_ below). If you get a 403 (Forbidden) upon trying to perform an action that typically works for you, request a new token from /token and retry your request with the new token.