-
Notifications
You must be signed in to change notification settings - Fork 14
Support for access token authorization #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
pleasant-menlo
wants to merge
3
commits into
IMAP-Science-Operations-Center:main
from
pleasant-menlo:main
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
|
@@ -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}} | ||||||
| ``` | ||||||
|
|
||||||
| To use an access token with imap-data-access you can set the following environment variables: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||
|
|
||||||
| ```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 | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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