From 3a6d15e3676483c2d0889ac637e756fe56cbaf33 Mon Sep 17 00:00:00 2001 From: skrivov-edb Date: Thu, 23 Sep 2021 20:17:22 -0400 Subject: [PATCH 1/8] docs(UPM-2380): Added docs for using shell script to get API tokens --- .../docs/edbcloud/beta/reference/index.mdx | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/product_docs/docs/edbcloud/beta/reference/index.mdx b/product_docs/docs/edbcloud/beta/reference/index.mdx index b6f3081a8ef..d7c3353f066 100644 --- a/product_docs/docs/edbcloud/beta/reference/index.mdx +++ b/product_docs/docs/edbcloud/beta/reference/index.mdx @@ -205,10 +205,66 @@ The response of this API call includes the `access_token`. For example: +## Getting Tokens Using Shell Script +To simplify process of getting tokens, EDB provides a [shell script](https://github.com/EnterpriseDB/cloud-utilities/tree/main/api). +### Prerequisites for using the shell script +Install [command-line JSON processor jq](https://stedolan.github.io/jq/) specific to your OS. +### Usage +You can use script `get-token.sh` to get tokens for EDB Cloud API +``` +Usage: +./get-token.sh [flags] [options] + +flags: +--format (-o) json | plain output format +--refresh [optional] query for tokens + again using given + this revokes and rotates the refresh + token. Please remember the newly + returned refresh_token for the next use. + +``` + +Example of getting tokens with user activation code + + +``` +./get-token.sh -o plain +Please login to +https://edbcloud.us.auth0.com/activate?user_code=ZMNX-VVJT +with your EDB Cloud account +Have you finished the login successfully? (y/N) y + +####### Access Token ################ +eyxxxxxxxxxxxxxx + +####### Refresh Token ############### +xxxxxxxxxx + +####### ID Token ############### +xxxxxxxxxxxx +##### Expires In Seconds ########## +86400 +``` + + + Example of getting tokens using refresh token + +``` +./get-token.sh -o json --refresh v1.MVZ9_xxxxxxxx_FRs +{ + "access_token": "xxxxxxxxxx", + "refresh_token": "xxxxxxxxxxxx", + "id_token": "xxxxxxxx", + "scope": "openid profile email offline_access", + "expires_in": 86400, + "token_type": "Bearer" +} +``` From 106de655584af681cb42214e0d763481074781f4 Mon Sep 17 00:00:00 2001 From: drothery-edb Date: Tue, 28 Sep 2021 13:58:10 -0400 Subject: [PATCH 2/8] first pass on doc team edits for get-tokens script first pass on doc team edits for get-tokens script --- .../docs/edbcloud/beta/reference/index.mdx | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/product_docs/docs/edbcloud/beta/reference/index.mdx b/product_docs/docs/edbcloud/beta/reference/index.mdx index d7c3353f066..2f585741cde 100644 --- a/product_docs/docs/edbcloud/beta/reference/index.mdx +++ b/product_docs/docs/edbcloud/beta/reference/index.mdx @@ -13,6 +13,8 @@ To access the API, you need a token. The high-level steps to obtain a token are: 4. [Request the token](#request-the-token). +EDB provides an optional script to simplify getting and refreshing your tokens. Steps 2-4 are automated by the script. See [Using the get-token Script](#using-the-get-token-script) for details. + ## Query the Authentication Endpoint @@ -44,7 +46,7 @@ The following example calls show use these environment variables. ## Request the Device code -Use the following call to get a device code: +If you are not using the get-token script, use the following call to get a device code: ``` curl --request POST \ --url "$ISSUER_URL/oauth/device/code" \ @@ -83,6 +85,8 @@ DEVICE_CODE=KEOY2_5YjuVsRuIrrR-aq5gs ## Authorize as a User +If you are not using the get-token script, use the following steps to authorize as a user: + 1. Go to the `verification_uri` in your web browser, enter your `user_code`, and select **Continue**. 4. Select **Confirm** on the Device Confirmation dialog. @@ -94,7 +98,7 @@ DEVICE_CODE=KEOY2_5YjuVsRuIrrR-aq5gs ## Request the Token -Use the `curl --request POST` command to request a token. For example, +If you are not using the get-token script, use the `curl --request POST` command to request a token. For example, ``` curl --request POST \ --url "$ISSUER_URL/oauth/token" \ @@ -171,11 +175,11 @@ Example response: ``` -## Refreshing your Token +## Refresh your Token You can use the refresh token to get a new access token. Usually you need a new access token only after the previous one expires or when gaining access to a new resource for the first time. You shouldn't call the endpoint to get a new access token every time you call an API. There are rate limits that throttle the amount of requests to the endpoint that can be executed using the same token from the same IP. -To refresh your token, make a POST request to the `/oauth/token` endpoint in the Authentication API, using `grant_type=refresh_token`. For example: +If you are not using the get-token script to refresh your token, make a POST request to the `/oauth/token` endpoint in the Authentication API, using `grant_type=refresh_token`. For example: ``` curl --request POST \ --url "$ISSUER_URL/oauth/token" \ @@ -205,17 +209,14 @@ The response of this API call includes the `access_token`. For example: -## Getting Tokens Using Shell Script - -To simplify process of getting tokens, EDB provides a [shell script](https://github.com/EnterpriseDB/cloud-utilities/tree/main/api). +## Using the get-token Script -### Prerequisites for using the shell script -Install [command-line JSON processor jq](https://stedolan.github.io/jq/) specific to your OS. +To simplify the process of getting tokens, EDB provides the get-token script. You can download it [here](https://github.com/EnterpriseDB/cloud-utilities/tree/main/api). -### Usage +To use the script, install the [jq command-line JSON processor](https://stedolan.github.io/jq/) specific to your OS. -You can use script `get-token.sh` to get tokens for EDB Cloud API +### get-token Usage ``` Usage: @@ -231,8 +232,8 @@ flags: ``` -Example of getting tokens with user activation code - +### Use get-token to Get your Tokens +To use the script to get your tokens, use script without the --refresh option. For example, ``` ./get-token.sh -o plain @@ -254,8 +255,8 @@ xxxxxxxxxxxx 86400 ``` - - Example of getting tokens using refresh token +### Use get-token to Refresh your Token + To use the script to refresh your token, use the script with the --refresh option. For example, ``` ./get-token.sh -o json --refresh v1.MVZ9_xxxxxxxx_FRs From a6a30fc45317a19a09182d8f8886a2c0fa32eb4a Mon Sep 17 00:00:00 2001 From: drothery-edb Date: Tue, 28 Sep 2021 14:58:51 -0400 Subject: [PATCH 3/8] incorporated Sergey's suggestions --- .../docs/edbcloud/beta/reference/index.mdx | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/product_docs/docs/edbcloud/beta/reference/index.mdx b/product_docs/docs/edbcloud/beta/reference/index.mdx index 2f585741cde..e7af83c0fb2 100644 --- a/product_docs/docs/edbcloud/beta/reference/index.mdx +++ b/product_docs/docs/edbcloud/beta/reference/index.mdx @@ -8,12 +8,12 @@ The API reference documentation is available from the [EDB Cloud portal](https:/ To access the API, you need a token. The high-level steps to obtain a token are: 1. [Query the authentication endpoint](#query-the-authentication-endpoint). -2. [Request the device code](#request-the-device-code). +2. [Request the device code](#request-the-device-code-using-curl). 3. [Authorize as a user](#authorize-as-a-user). -4. [Request the token](#request-the-token). +4. [Request the token](#request-the-token-using-curl). -EDB provides an optional script to simplify getting and refreshing your tokens. Steps 2-4 are automated by the script. See [Using the get-token Script](#using-the-get-token-script) for details. +You can perform all the steps using CURL, but EDB provides an optional script to simplify getting and refreshing your tokens. The script automates steps 2-4. See [Using the get-token Script](#using-the-get-token-script) for details. ## Query the Authentication Endpoint @@ -44,9 +44,9 @@ AUDIENCE="https://portal.edbcloud.com/api" ``` The following example calls show use these environment variables. -## Request the Device code +## Request the Device Code Using Curl -If you are not using the get-token script, use the following call to get a device code: +Use the following call to get a device code: ``` curl --request POST \ --url "$ISSUER_URL/oauth/device/code" \ @@ -58,7 +58,7 @@ curl --request POST \ The response returns: -- `device_code` - the unique code for the device. When you go to the `verification_uri` in your browser-based device, this code is bound to your session. You use this code in your [request for a token](#request-the-token). +- `device_code` - the unique code for the device. When you go to the `verification_uri` in your browser-based device, this code is bound to your session. You use this code in your [request for a token](#request-the-token-using-curl). - `user_code` - the code you input at the `verification_uri` to authorize the device. You use this code when you [authorize yourself as a user](#authorize-as-a-user). - `verification_uri` - the URL you use to authorize your device. - `verification_uri_complete` - the complete URL you use to authorize the device. You can use this URL to embed the user code in your app's URL. @@ -96,9 +96,9 @@ If you are not using the get-token script, use the following steps to authorize 6. Log in with your Azure AD credentials. -## Request the Token +## Request the Token Using CURL -If you are not using the get-token script, use the `curl --request POST` command to request a token. For example, +Use the `curl --request POST` command to request a token. For example, ``` curl --request POST \ --url "$ISSUER_URL/oauth/token" \ @@ -133,9 +133,9 @@ REFRESH_TOKEN="v1.MTvuZpu.......sbiionEhtTw" ``` If not successful, you receive one of the following errors: -- `authorization_pending` - continue polling using the suggested interval retrieved when you [requested the device code](#request-the-device-code). +- `authorization_pending` - continue polling using the suggested interval retrieved when you [requested the device code](#request-the-device-code-using-curl). -- `slow_down` - slow down and use the suggested interval retrieved when you [requested the device code](#request-the-device-code). To avoid receiving this error due to network latency, you should start counting each interval after receipt of the last polling request's response. +- `slow_down` - slow down and use the suggested interval retrieved when you [requested the device code](#request-the-device-code-using-curl). To avoid receiving this error due to network latency, you should start counting each interval after receipt of the last polling request's response. - `expired_token` - you have not authorized the device quickly enough, so the `device_code` has expired. Your application should notify you that it has expired and to restore it. - `access_denied` @@ -175,10 +175,11 @@ Example response: ``` -## Refresh your Token +## Refresh your Token You can use the refresh token to get a new access token. Usually you need a new access token only after the previous one expires or when gaining access to a new resource for the first time. You shouldn't call the endpoint to get a new access token every time you call an API. There are rate limits that throttle the amount of requests to the endpoint that can be executed using the same token from the same IP. +### Refresh your Token Using CURL If you are not using the get-token script to refresh your token, make a POST request to the `/oauth/token` endpoint in the Authentication API, using `grant_type=refresh_token`. For example: ``` curl --request POST \ @@ -232,7 +233,7 @@ flags: ``` -### Use get-token to Get your Tokens +### Use get-token to Get the Tokens To use the script to get your tokens, use script without the --refresh option. For example, ``` @@ -255,7 +256,7 @@ xxxxxxxxxxxx 86400 ``` -### Use get-token to Refresh your Token +### Use get-token to Refresh the Token To use the script to refresh your token, use the script with the --refresh option. For example, ``` From 1af996ed9bd52ea11961c523faaff4b4ca1f92c8 Mon Sep 17 00:00:00 2001 From: drothery-edb Date: Wed, 29 Sep 2021 10:16:59 -0400 Subject: [PATCH 4/8] Incorporated Ben's comments updated font treatments updated section titled for consistency other small edits --- .../docs/edbcloud/beta/reference/index.mdx | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/product_docs/docs/edbcloud/beta/reference/index.mdx b/product_docs/docs/edbcloud/beta/reference/index.mdx index e7af83c0fb2..dd464b4e670 100644 --- a/product_docs/docs/edbcloud/beta/reference/index.mdx +++ b/product_docs/docs/edbcloud/beta/reference/index.mdx @@ -13,7 +13,7 @@ To access the API, you need a token. The high-level steps to obtain a token are: 4. [Request the token](#request-the-token-using-curl). -You can perform all the steps using CURL, but EDB provides an optional script to simplify getting and refreshing your tokens. The script automates steps 2-4. See [Using the get-token Script](#using-the-get-token-script) for details. +You can perform all the steps using `curl`, but EDB provides an optional script to simplify getting and refreshing your tokens. The script automates steps 2-4. See [Using the `get-token` Script](#using-the-get-token-script) for details. ## Query the Authentication Endpoint @@ -34,7 +34,7 @@ The response returns the `clientId`, `issuerUri`, `scope`, and `audience`. For e } ``` -EDB recommends you store the output in environment variables to make including them in the following calls easier. For example, +EDB recommends you store the output in environment variables to make including them in the following calls easier. For example: ``` CLIENT_ID=pM8PRguGtW9yVnrsvrvpaPyyeS9fVvFh @@ -42,9 +42,9 @@ ISSUER_URL=https://auth.edbcloud.com SCOPE="openid profile email offline_access" AUDIENCE="https://portal.edbcloud.com/api" ``` -The following example calls show use these environment variables. +The following example calls use these environment variables. -## Request the Device Code Using Curl +## Request the Device Code Using `curl` Use the following call to get a device code: ``` @@ -77,7 +77,7 @@ For example: } ``` -Store the device_code in an environment variable for future use. For example; +Store the device_code in an environment variable for future use. For example: ``` DEVICE_CODE=KEOY2_5YjuVsRuIrrR-aq5gs @@ -85,7 +85,7 @@ DEVICE_CODE=KEOY2_5YjuVsRuIrrR-aq5gs ## Authorize as a User -If you are not using the get-token script, use the following steps to authorize as a user: +If you are not using the `get-token` script, use the following steps to authorize as a user: 1. Go to the `verification_uri` in your web browser, enter your `user_code`, and select **Continue**. @@ -96,9 +96,9 @@ If you are not using the get-token script, use the following steps to authorize 6. Log in with your Azure AD credentials. -## Request the Token Using CURL +## Request the Token Using `curl` -Use the `curl --request POST` command to request a token. For example, +Use the `curl --request POST` command to request a token. For example: ``` curl --request POST \ --url "$ISSUER_URL/oauth/token" \ @@ -125,7 +125,7 @@ For example: "token_type": "Bearer" } ``` -Store the access_token and refresh_token in environment variables for future use. For example, +Store the access_token and refresh_token in environment variables for future use. For example: ``` ACCESS_TOKEN="eyJhbGc.......1Qtkaw2fyho" @@ -179,8 +179,8 @@ Example response: You can use the refresh token to get a new access token. Usually you need a new access token only after the previous one expires or when gaining access to a new resource for the first time. You shouldn't call the endpoint to get a new access token every time you call an API. There are rate limits that throttle the amount of requests to the endpoint that can be executed using the same token from the same IP. -### Refresh your Token Using CURL -If you are not using the get-token script to refresh your token, make a POST request to the `/oauth/token` endpoint in the Authentication API, using `grant_type=refresh_token`. For example: +### Refresh your Token Using `curl` +If you are not using the `get-token` script to refresh your token, make a POST request to the `/oauth/token` endpoint in the Authentication API, using `grant_type=refresh_token`. For example: ``` curl --request POST \ --url "$ISSUER_URL/oauth/token" \ @@ -210,10 +210,10 @@ The response of this API call includes the `access_token`. For example: -## Using the get-token Script +## Using the `get-token` Script -To simplify the process of getting tokens, EDB provides the get-token script. You can download it [here](https://github.com/EnterpriseDB/cloud-utilities/tree/main/api). +To simplify the process of getting tokens, EDB provides the `get-token` script. You can download it [here](https://github.com/EnterpriseDB/cloud-utilities/tree/main/api). To use the script, install the [jq command-line JSON processor](https://stedolan.github.io/jq/) specific to your OS. @@ -233,8 +233,8 @@ flags: ``` -### Use get-token to Get the Tokens -To use the script to get your tokens, use script without the --refresh option. For example, +### Request Your Token Using `get-token` +To use the script to get your tokens, use script without the `--refresh` option. For example: ``` ./get-token.sh -o plain @@ -256,8 +256,8 @@ xxxxxxxxxxxx 86400 ``` -### Use get-token to Refresh the Token - To use the script to refresh your token, use the script with the --refresh option. For example, +### Refresh the Token Using `get-token` + To use the script to refresh your token, use the script with the `--refresh` option. For example: ``` ./get-token.sh -o json --refresh v1.MVZ9_xxxxxxxx_FRs From b952bf6910a9a1e27102cb32c81c02939ababd94 Mon Sep 17 00:00:00 2001 From: skrivov-edb Date: Wed, 29 Sep 2021 17:51:59 -0400 Subject: [PATCH 5/8] docs(UPM-2380): fixes in Authorize the Useer --- .../docs/edbcloud/beta/reference/index.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/product_docs/docs/edbcloud/beta/reference/index.mdx b/product_docs/docs/edbcloud/beta/reference/index.mdx index dd464b4e670..ca3553f275c 100644 --- a/product_docs/docs/edbcloud/beta/reference/index.mdx +++ b/product_docs/docs/edbcloud/beta/reference/index.mdx @@ -85,15 +85,15 @@ DEVICE_CODE=KEOY2_5YjuVsRuIrrR-aq5gs ## Authorize as a User -If you are not using the `get-token` script, use the following steps to authorize as a user: +Use the following steps to authorize as a user: 1. Go to the `verification_uri` in your web browser, enter your `user_code`, and select **Continue**. -4. Select **Confirm** on the Device Confirmation dialog. +2. Select **Confirm** on the Device Confirmation dialog. -5. Select **Continue with Microsoft Azure AD** on the EDB Cloud Welcome screen. +3. Select **Continue with Microsoft Azure AD** on the EDB Cloud Welcome screen. -6. Log in with your Azure AD credentials. +4. Log in with your Azure AD credentials. ## Request the Token Using `curl` @@ -175,7 +175,7 @@ Example response: ``` -## Refresh your Token +## Refresh your Token You can use the refresh token to get a new access token. Usually you need a new access token only after the previous one expires or when gaining access to a new resource for the first time. You shouldn't call the endpoint to get a new access token every time you call an API. There are rate limits that throttle the amount of requests to the endpoint that can be executed using the same token from the same IP. @@ -233,7 +233,7 @@ flags: ``` -### Request Your Token Using `get-token` +### Request Your Token Using `get-token` To use the script to get your tokens, use script without the `--refresh` option. For example: ``` @@ -256,7 +256,7 @@ xxxxxxxxxxxx 86400 ``` -### Refresh the Token Using `get-token` +### Refresh the Token Using `get-token` To use the script to refresh your token, use the script with the `--refresh` option. For example: ``` From 00383395eab186c33e39d0e32569bee9cc0ae833 Mon Sep 17 00:00:00 2001 From: skrivov-edb Date: Wed, 29 Sep 2021 18:03:52 -0400 Subject: [PATCH 6/8] docs(UPM-2380): fix refresh token language --- product_docs/docs/edbcloud/beta/reference/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product_docs/docs/edbcloud/beta/reference/index.mdx b/product_docs/docs/edbcloud/beta/reference/index.mdx index ca3553f275c..a6e506b289e 100644 --- a/product_docs/docs/edbcloud/beta/reference/index.mdx +++ b/product_docs/docs/edbcloud/beta/reference/index.mdx @@ -257,7 +257,7 @@ xxxxxxxxxxxx ``` ### Refresh the Token Using `get-token` - To use the script to refresh your token, use the script with the `--refresh` option. For example: + To use the script to refresh your tokens, use the script with the refresh token after the `--refresh` option. For example: ``` ./get-token.sh -o json --refresh v1.MVZ9_xxxxxxxx_FRs From 0f2ea350448a432a8f9c4df1f55884725de34ba9 Mon Sep 17 00:00:00 2001 From: drothery-edb <83650384+drothery-edb@users.noreply.github.com> Date: Thu, 30 Sep 2021 08:19:50 -0400 Subject: [PATCH 7/8] minor edit to "Refresh the Token Using get-token" --- product_docs/docs/edbcloud/beta/reference/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product_docs/docs/edbcloud/beta/reference/index.mdx b/product_docs/docs/edbcloud/beta/reference/index.mdx index a6e506b289e..1913dc3be5f 100644 --- a/product_docs/docs/edbcloud/beta/reference/index.mdx +++ b/product_docs/docs/edbcloud/beta/reference/index.mdx @@ -257,7 +257,7 @@ xxxxxxxxxxxx ``` ### Refresh the Token Using `get-token` - To use the script to refresh your tokens, use the script with the refresh token after the `--refresh` option. For example: + To use the script to refresh your tokens, use the script with the `--refresh ` option. For example: ``` ./get-token.sh -o json --refresh v1.MVZ9_xxxxxxxx_FRs From 1ead549eba4f823957cf5e480086cdbe1796174c Mon Sep 17 00:00:00 2001 From: drothery-edb Date: Thu, 30 Sep 2021 14:02:31 -0400 Subject: [PATCH 8/8] additional edits --- .../docs/edbcloud/beta/reference/index.mdx | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/product_docs/docs/edbcloud/beta/reference/index.mdx b/product_docs/docs/edbcloud/beta/reference/index.mdx index dd464b4e670..416b6f844a6 100644 --- a/product_docs/docs/edbcloud/beta/reference/index.mdx +++ b/product_docs/docs/edbcloud/beta/reference/index.mdx @@ -13,12 +13,16 @@ To access the API, you need a token. The high-level steps to obtain a token are: 4. [Request the token](#request-the-token-using-curl). -You can perform all the steps using `curl`, but EDB provides an optional script to simplify getting and refreshing your tokens. The script automates steps 2-4. See [Using the `get-token` Script](#using-the-get-token-script) for details. +EDB provides an optional script to simplify getting your device code and getting and refreshing your tokens. See [Using the `get-token` Script](#using-the-get-token-script) for details. ## Query the Authentication Endpoint -Use the following command to get the information returned by the authentication endpoint that you need later: +This call returns the information that either: + +- you need later if you are using `curl` to request the device code and tokens, or +- the `get-token` script uses to generate the tokens for you + ``` curl https://portal.edbcloud.com/api/v1/auth/provider @@ -45,8 +49,10 @@ AUDIENCE="https://portal.edbcloud.com/api" The following example calls use these environment variables. ## Request the Device Code Using `curl` - -Use the following call to get a device code: +!!!note + The `get-token` script executes this step. You don't need to make this call if you are using the script. +!!! +This call gets a device code: ``` curl --request POST \ --url "$ISSUER_URL/oauth/device/code" \ @@ -77,7 +83,7 @@ For example: } ``` -Store the device_code in an environment variable for future use. For example: +Store the device code in an environment variable for future use. For example: ``` DEVICE_CODE=KEOY2_5YjuVsRuIrrR-aq5gs @@ -85,7 +91,7 @@ DEVICE_CODE=KEOY2_5YjuVsRuIrrR-aq5gs ## Authorize as a User -If you are not using the `get-token` script, use the following steps to authorize as a user: +To authorize as a user: 1. Go to the `verification_uri` in your web browser, enter your `user_code`, and select **Continue**. @@ -97,8 +103,11 @@ If you are not using the `get-token` script, use the following steps to authoriz ## Request the Token Using `curl` +!!!note + The `get-token` script executes this step. You don't need to make this call if you are using the script. See [Request Your Token Using `get-token`](#request-your-token-using-get-token). +!!! -Use the `curl --request POST` command to request a token. For example: +The `curl --request POST` call requests a token. For example: ``` curl --request POST \ --url "$ISSUER_URL/oauth/token" \ @@ -125,7 +134,7 @@ For example: "token_type": "Bearer" } ``` -Store the access_token and refresh_token in environment variables for future use. For example: +Store the access token and refresh token in environment variables for future use. For example: ``` ACCESS_TOKEN="eyJhbGc.......1Qtkaw2fyho" @@ -177,9 +186,13 @@ Example response: ## Refresh your Token -You can use the refresh token to get a new access token. Usually you need a new access token only after the previous one expires or when gaining access to a new resource for the first time. You shouldn't call the endpoint to get a new access token every time you call an API. There are rate limits that throttle the amount of requests to the endpoint that can be executed using the same token from the same IP. +You use the refresh token to get a new access token. Usually you need a new access token only after the previous one expires or when gaining access to a new resource for the first time. You shouldn't call the endpoint to get a new access token every time you call an API. There are rate limits that throttle the amount of requests to the endpoint that can be executed using the same token from the same IP. ### Refresh your Token Using `curl` +!!!note +The `get-token` script has an option to execute this step. See [Refresh the Token Using `get-token`](#refresh-the-token-using-get-token). +!!! + If you are not using the `get-token` script to refresh your token, make a POST request to the `/oauth/token` endpoint in the Authentication API, using `grant_type=refresh_token`. For example: ``` curl --request POST \ @@ -206,7 +219,7 @@ The response of this API call includes the `access_token`. For example: ``` !!! Note - You need to save the `refresh_token` retrieved from this response for the next refresh call. The `refresh_token` in the response when you originally [requested the token](#request-the-token) is obsoleted once it has been used. + You need to save the refresh token retrieved from this response for the next refresh call. The refresh token in the response when you originally [requested the token](#request-the-token) is obsoleted once it has been used. @@ -217,6 +230,8 @@ To simplify the process of getting tokens, EDB provides the `get-token` script. To use the script, install the [jq command-line JSON processor](https://stedolan.github.io/jq/) specific to your OS. +Before running the script, [query the authentication endpoint](#query-the-authentication-endpoint). + ### get-token Usage ``` @@ -234,7 +249,7 @@ flags: ``` ### Request Your Token Using `get-token` -To use the script to get your tokens, use script without the `--refresh` option. For example: +To use the `get-token` script to get your tokens, use the script without the `--refresh` option. For example: ``` ./get-token.sh -o plain @@ -255,9 +270,8 @@ xxxxxxxxxxxx ##### Expires In Seconds ########## 86400 ``` - ### Refresh the Token Using `get-token` - To use the script to refresh your token, use the script with the `--refresh` option. For example: + To use the `get-token` script to refresh your token, use the script with the `--refresh ` option. For example: ``` ./get-token.sh -o json --refresh v1.MVZ9_xxxxxxxx_FRs @@ -270,3 +284,4 @@ xxxxxxxxxxxx "token_type": "Bearer" } ``` +