FAQ
- Best Practices for Storing / Protecting API Keys
- How to delete an API when there are other users subscribed to it?
- How do I test an API in the developer portal?
- Who can access the APIs?
- What is an API key?
- How do I register an app / application?
- How do I access an API?
- How do I setup a non-UCSD person to access UCSD published APIs?
Best Practices for Storing / Protecting API Keys
What are some best practices and recommendations on how to store and protect API keys?
Store API keys / secrets safely
- Do not embedAPIkeys/secretsdirectlyin code.
- Do not storeAPIkeys/secretsinfiles inside your application, include the application’s source tree
- If you do accidentally commit anAPIkey/secretstoversion control, revoke it immediately and generate a new one.
- EnsureAPIkeys/secretsnotappear in URLsoranywherecanbe captured in web server logs.
- Review your code carefully and ensure it doesn’t containAPIkeys/secretsorany other private information before publicly releasing it.
- Put the configuration file containing theAPIkeys/secretsinthe revision control ignore. This prevents committing them by mistake in the future.
Limit the usage of API keys / secrets
- Restrict yourAPIkeys/secretstobe used by only the IP addresses, referrer URLs, and mobile apps that need them.
- Don't share yourAPIkeys/secretswithdifferent applications. If more than one application uses the same API, register each application to get a new set ofAPIkeys/ secrets.
Update API keys / secrets
- Delete unneededAPIkeys/ secrets.
- Update (Regenerate) yourAPIkeys/secretsperiodically.
References
- Best practices for securely using API keys:Â https://support.google.com/cloud/answer/6310037?hl=en
- REST Security Cheat Sheet - OWASP:Â https://www.owasp.org/index.php/REST_Security_Cheat_Sheet
Â
How to delete an API when there are other users subscribed to it?
In publisher interface, there’s a lifecycles tab. Here you can set the API to deprecated and then to retired.Â
When retired all existing subscriptions are dropped.Â
You can then delete the API.Â
Be sure you’re deleting the right one as there’s no way to undo this action.
How do I test an API in the developer portal?
How can I view what data is returned by an API? How can I test an API using my web browser?
In order to view the data provided by an API or test it using this developer portal, follow the steps below.
Get the Consumer Key and Secret
- Browse the documentation of the available APIs to help you select one
- Register your application
- Depending on the API you request access to, the approval may take a couple of days or be automatic
- Go to My Apps and select the application you just registered. Select Generate/Re-generate button
- Copy the "Consumer Key" and "Consumer Secret" for use in the section below (as client id and client secret respectively)
Make the API call
- Use the client id (consumer key) and client key (consumer secret) from the steps above to get an access token.
- Select the API corresponding to the product that you registered in the previous section
- Click on the "getAccesToken" methodÂ
- Enter "client_credentials" under grant type
- Enter the client id (consumer key) and client key (consumer secret) from your registered application
- Click on the "Send this request" button
- View the response and save the "access_token" value
- Use the access token to make API calls
- Select the API corresponding to the product that you used to get the access token in the previous section
- Click on any method except for "getAccessToken"
- Enter "Bearer XXXX" under the Authorization header, where XXX is the access token
- Enter any required query parameters or url parameters
- Click on the "Send this request" button
Who can access the APIs?
Who can access the APIs? Can people not affiliated to UCSD access the APIs?
The APIs are available to UCSD developers (staff, student and faculty) who have an Single Sign-on account. At this point, the APIs are not open to developers outside of UCSD. Some APIs have more restrictions or require approvals, which limit the access to them. These restrictions can be found within the documentation of each API.
Â
How do I register an app / application?
In order to access data you need an API key. To get an API key, you need to register an application or app. Only UCSD developers with an SSOÂ account can register an application / app. The steps below, walk you through how to register an app:
How do I access an API?
I want to access data provided by an API. How do I make a call to the API to get the data?
In order to access the data provided by an API, follow the steps below.
Get the Consumer Key and Secret
- Create your application or use the default application -Â https://api-qa.ucsd.edu/store/site/pages/applications.jag
- Go to DEV/QA/PROD section and copy the "Consumer Key" and "Consumer Secret" for use in the section below (as client id and client secret respectively)
- Browse the documentation of the available APIs ( https://api[-qa].ucsd.edu/store/Â )Â and subscribe to the one you are interested in
- Depending on the API you request access to, the approval may take a couple of days or be automatic
Make the API call
- HTTP request to get an access token:
curl -X POST --header "Content-Type: application/x-www-form-urlencoded;charset=utf-8" -d "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET" "https://api[-qa].ucsd.edu/<API-ENDPOINT>/token"
HTTP to make a request to the API using the access token:
curl -X GET --header "Content-Type: application/x-www-form-urlencoded;charset=utf-8" --header "Authorization: Bearer ACCESS_TOKEN" "https://api[-qa].ucsd.edu/<API-ENDPOINT>"
How do I setup a non-UCSD person to access UCSD published APIs?
The API manager uses UCSD business system to authenticate user for self-service portal and to provide access keys.Â
 In order to provide access to someone without access to UCSD business system, one of the UCSD employees will have to act as a proxy to generate key and secret on their behalf.