Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ an API Key, which can be requested from the SDC team.
To use the API Key you can set environment variables and then use
the tool as usual. Note that the api endpoints are prefixed with `/api-key`
to request unreleased data. This will also require an update to the
data access url. So the following should be used when programatically
data access url. So the following should be used when programmatically
accessing the data.

```bash
Expand All @@ -155,6 +155,35 @@ or with CLI flags
imap-data-access --api-key <your-api-key> --url https://api.dev.imap-mission.com/api-key ...
```

### Automated use with Access token

An alternative to using an API key to access protected data is using an access token provided by LASP's authentication server. LASP's authentication uses [keycloak authentication](https://www.keycloak.org/documentation). Below are the minimal steps to get an access token:

1. Make a POST request to: `https://lasp-auth.colorado.edu/auth/realms/lasp/protocol` with the request Content-Type as `x-www-form-urlencoded` and body:
```
client_id: imap-sdc
grant_type: password
username: {{Your LASP galaxy username}}
password: {{Your LASP galaxy password}}
```

2. This should return a JSON response that contains an access token that is valid for 5 minutes. It will also contain a longer-lived refresh token that can be used to get more access tokens with a request to the same url as above, but the following body:

```
client_id: imap-sdc
grant_type: refresh_token
refresh_token: {{Refresh Token}}
```
Comment on lines +162 to +176
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an awesome write-up! Unfortunately, I did have a request from our web team to not overly publicize the token endpoints. Could we move this content into the Confluence Galaxy somewhere? I don't know where a good spot is... there was a recent "manuals heading" for releases here https://lasp.colorado.edu/galaxy/spaces/IMAP/pages/292754433/Manuals


To use an access token with imap-data-access you can set the following environment variables:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this section, I think this is the important piece for users.

Suggested change
To use an access token with imap-data-access you can set the following environment variables:
To use an access token with imap-data-access you can set the following environment variables (note the `/authorized` trailing path):


```dotenv
IMAP_ACCESS_TOKEN={{Access token from above}}
IMAP_DATA_ACCESS_URL=https://api.imap-mission.com/authorized
```

Any queries or downloads made with imap-data-access will now use these credentials.

## Troubleshooting

### Network issues
Expand Down