In addition to using the Ego Admin UI, you may also interact with Ego using the following methods:
Using cURL commands in the command line
Using the Swagger UI
Mode | URL |
---|---|
Local | http://localhost:8080/swagger-ui.html |
Server | https://<YOUR-URL>/ego-api/swagger-ui.html# |
In both of these scenarios, the user or application must first authenticate with the Ego API. The sections below describe how to authenticate with and use the Ego API.
Log into the Ego-UI, and from the profile menu found in on the bottom of the left-hand panel select, Copy My JWT.
Next, we will use the Ego API to generate an API Key for another user, so that they have WRITE
access to both Song and Score.
ID
of the user, as it will be required when supplying the necessary parameters to the relevant endpoint.The example we provide here is applicable to all Ego API endpoints. Using other endpoints follows a similar process, where you must first authorize with the API, then supply the necessary input parameters to the desired endpoint. Both Swagger UI and cURL are available to make requests to the API.
To generate an API Key using the Swagger UI:
Go to the swagger UI for your installation at <url>/ego-api/swagger-ui.html
, where <url>
is the base URL where Ego is deployed.
In the top right, click the Authorize button (open lock icon):
Value
box, enter the following:Bearer <JWT>
Where <JWT>
is the Ego Admin JWT you recorded earlier in the prerequisite steps.
POST
endpoint called issueApiKey
. The endpoint input parameters are displayed:Param | Description |
---|---|
description | Optional description of the API Key being generated. |
scopes | Enter the specific scopes or permissions to grant for this API Key. In our example, we want to provide WRITE access to the SONG and SCORE policies. Hence, we add an entry for each of SONG.WRITE and SCORE.WRITE . |
user_id | ID of the user that you recorded earlier from the Ego Admin UI, for whom this API Key is being generated. |
{"name": "1a1a72a4-224f-41a0-9825-c0dacadba228","scope": ["SONG.WRITE","SCORE.WRITE"],"expiryDate": "2021-05-06T01:42:35.228+0000","issueDate": "2021-04-06T01:42:35.228+0000","isRevoked": false,"description": null}
ACTIVE
API Key with the correct permissions has been generated in that user's profile:To generate the API Key via a cURL command:
curl -X POST "<url>/ego-api/o/api_key?scopes=<scope1>&scopes=<scope2>&user_id=<userId>" -H "accept: application/json" -H "Authorization: Bearer <JWT>"
Where:
<url>
is the base URL you have deployed Ego to<scope1>
, <scope2>
, etc. are the specific scopes you want to assign - In our example it will be SONG.WRITE
and SCORE.WRITE
<userId>
is the internal Ego ID for the user that the API Key is being generated for<JWT>
is the Ego Admin JWT you recorded earlier For example:
curl -X POST "https://dms.test.cancercollaboratory.org/ego-api/o/api_key?scopes=SONG.WRITE&scopes=SCORE.WRITE&user_id=88d45eb5-8d43-41ec-9af5-ad956f3a7fb6" -H "accept: application/json" -H "Authorization: Bearer <JWT>"
{"name":"5c93077b-bcd6-4840-bad2-5dc3672eec50","scope":["SONG.WRITE","SCORE.WRITE"],"expiryDate":"2021-05-06T02:13:34.559+0000","issueDate":"2021-04-06T02:13:34.559+0000","isRevoked":false,"description":null}
ACTIVE
API Key with the correct permissions has been generated in that user's profile: