Skip to content

Commit b80977f

Browse files
authored
Dropbox connectors: access tokens valid for only four hours; how to refresh expired tokens (#471)
1 parent 6162db1 commit b80977f

File tree

1 file changed

+74
-1
lines changed

1 file changed

+74
-1
lines changed

snippets/general-shared-text/dropbox.mdx

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ allowfullscreen
2525
This is because the access token is scoped to the specific app folder and settings at the time the access token is generated. If you change the app folder name or any of the permissions later,
2626
you should regenerate the access token.<br/>
2727

28+
<Warning>
29+
Access tokens are valid for **only four hours** after they are created. After this four-hour period, you can no longer use the expired access token.
30+
Dropbox does not allow the creation of access tokens that are valid for more than four hours.
31+
32+
To generate a replacement token for an expired one, see [Replace an expired access token](#replace-an-expired-access-token), later in this article.
33+
</Warning>
34+
2835
3. The app folder that your Dropbox app will use for access can be found in your Dropbox account under the `Apps` top-level folder. For example, if the value of the **App folder name**
2936
field above is `my-folder`, then the app folder that your Dropbox app will use for access can be found under `https://dropbox.com/home/Apps/my-folder`
3037

@@ -43,4 +50,70 @@ allowfullscreen
4350
if your Dropbox app uses an app folder named `my-folder` for access within the `Apps` top-level folder, and you create a subfolder named `data` within the `my-folder` app folder, then
4451
the remote URL is `dropbox://data`
4552

46-
![The data subfolder under the my-folder subfolder](/img/connectors/dropbox-app-subfolder.png)
53+
![The data subfolder under the my-folder subfolder](/img/connectors/dropbox-app-subfolder.png)
54+
55+
## Replace an expired access token
56+
57+
Dropbox app access tokens are valid for **only four hours**. After this time, you can no longer use the expired access token.
58+
59+
To replace an old, expired access token with a new, valid one, do the following:
60+
61+
1. Get the app key and app secret values for your Dropbox app. To do this:
62+
63+
a) Sign in to the [Dropbox Developers](https://www.dropbox.com/developers) portal with the same credentials as your Dropbox account.<br/>
64+
b) Open your [App Console](https://www.dropbox.com/developers/apps).<br/>
65+
c) Click your Dropbox app's icon.<br/>
66+
d) On the **Settings** tab, next to **App key**, copy the value of the app key.<br/>
67+
e) Next to **App secret**, click **Show**, and then copy the value of the app secret.
68+
69+
2. Use your web browser to browse to the following URL, replacing `<app-key>` with the app key for your Dropbox app:
70+
71+
```text
72+
https://www.dropbox.com/oauth2/authorize?client_id=<app-key>&response_type=code&token_access_type=offline
73+
```
74+
75+
3. Click **Continue**.
76+
4. Click **Allow**.
77+
5. In the **Access code generated** tile, copy the access code that is shown.
78+
6. Use the [curl](https://curl.se/) utility in your Terminal or Command Prompt, or use a REST API client such as
79+
[Postman](https://www.postman.com/product/api-client/), to make the following REST API call, replacing the following placeholders:
80+
81+
- Replace `<access-code>` with the access code that you just copied.
82+
- Replace `<app-key>` with the app key for your Dropbox app.
83+
- Replace `<app-secret>` with the app secret for your Dropbox app.
84+
85+
```text
86+
curl https://api.dropbox.com/oauth2/token \
87+
--data code=<access-code> \
88+
--data grant_type=authorization_code \
89+
--user <app-key>:<app-secret>
90+
```
91+
92+
7. In the response, copy the following two values:
93+
94+
- The value of `access_token` (starting with the characters `sl`) is the new, valid access token. In your Dropbox connector settings, replace the old,
95+
expired access token value with this new, valid access token value.
96+
- The value of `refresh_token` is the refresh token that you can use to replace this access token much faster and easier next time.
97+
If you lose this refresh token, you must go back to Step 2.
98+
99+
8. To use the refresh token to replace the expired access token, make the following REST API call, replacing the following placeholders:
100+
101+
- Replace `<refresh-token>` with the refresh token.
102+
- Replace `<app-key>` with the app key for your Dropbox app.
103+
- Replace `<app-secret>` with the app secret for your Dropbox app.
104+
105+
```text
106+
curl https://api.dropbox.com/oauth2/token \
107+
--data refresh_token=<refresh-token> \
108+
--data grant_type=refresh_token \
109+
--data client_id=<app-key> \
110+
--data client_secret=<app-secret>
111+
```
112+
113+
9. In the response, copy the following two values:
114+
115+
- The value of `access_token` (starting with the characters `sl`) is the new, valid access token. In the connector, replace the old,
116+
expired access token value with this new, valid access token value.
117+
- The value of `refresh_token` is the new, valid refresh token. To replace the expired access token, go back to Step 8.
118+
119+

0 commit comments

Comments
 (0)