From 2c865d57e26ed2b8534fca32842e24d78bb67682 Mon Sep 17 00:00:00 2001 From: Bearz314 Date: Thu, 22 Nov 2018 23:52:03 +1100 Subject: [PATCH] Added example on API Tokens (#22460) * Added info on API Tokens Added some information on what tokens are. * Added code to demonstrate access token Added sample CURL code from Dropbox to illustrate the use of access token. --- .../computer-science/what-is-an-api/index.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/guide/english/computer-science/what-is-an-api/index.md b/guide/english/computer-science/what-is-an-api/index.md index 0b07baa32a..b993a827f4 100644 --- a/guide/english/computer-science/what-is-an-api/index.md +++ b/guide/english/computer-science/what-is-an-api/index.md @@ -53,6 +53,19 @@ In the example above, a developer made a request for the current weather at a sp
  • Facebook: https://developers.facebook.com/docs/facebook-login/login-flow-for-web
  • +## API Tokens + +Generally, before using an API from service, you will be required to register your app or open an account with the service. You will then be given a unique key / token / secret / code which acts as a form of authentication. The service will know who is requesting the information. For example, it is not uncommon for services to offer free API calls to indie developers, but require payments if the number of API calls you make in a period of time exceeds their threshold. Tokens can also be revoked if the service determines that the APIs have been abused, so it is important to check the terms and conditions. These tokens should be kept secret. + +For example, this is the API call for Dropbox to [list folders](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_folders). +``` +curl -X POST https://api.dropboxapi.com/2/sharing/list_folders \ + --header "Authorization: Bearer " \ + --header "Content-Type: application/json" \ + --data "{\"limit\": 100,\"actions\": []}" +``` +Without an access token obtained from Dropbox, the API call will not work. + #### More Information: * [API for non-programmers](https://schoolofdata.org/2013/11/18/web-apis-for-non-programmers/) * [Wikipedia](https://en.wikipedia.org/wiki/Application_programming_interface)