provide dropbox token related tooling
MIT License
HowTo get Dropbox refresh-token and/or access-token (console interactive mode)
npm i -g dropbox-refresh-token@latest
get_refresh_token
# follow instructions
NB: get_refresh_token
binary has some alias : drt
and dropbox_get_refresh_token
.
NB2: if you have cloned this project you could instead invoke this with ./bin/get_refresh_token.js
Short context about Dropbox long-lived tokens (and offline mode access).
Dropbox didn't provide anymore (since On September 30th, 2021) long-live access token from dropbox portal (src). This was the way to use token for offline applications.
Now, in order to access offline to dropbox services without having to login, you will need an offline refresh-token. And with this token you application is able to request a short-lived access token to call Dropbox API.
Here are the steps:
Having this refresh-token in "offline" mode (without login requirement) you could then each time needed:
access-code
and access-token
means 14400 sec (4 hours) - this ttl is provided in dropbox response when asking for this code/token.refresh-token
(seems to) means valid until revoked (src).Implement refresh tokens
Feature for a given DropBox app (appKey, appSecret).
getShortLivedAccessCodeUrlViaLoginUrl(appKey)
getRefreshToken(shortLivedAccessCode, appKey, appSecret, logToken = false)
refreshAccessToken(refresh_token, appKey, appSecret, logToken = false)
npm i dropbox-refresh-token
import {
isSet, getShortLivedAccessCodeUrlViaLoginUrl,
getRefreshToken, refreshAccessToken
} from "dropbox-refresh-token";
import {
isSet, getCurrentAccount, isAccessTokenValid
} from "dropbox-refresh-token";
<!> original idea is FranklinThaker/Dropbox-API-Uninterrupted-Access which provide (webApplication mode)
This workflow rely on environment variables and require project install (cf. § quickstart for more modern workflow)
git clone https://github.com/boly38/dropbox-refresh-token.git
cd dropbox-refresh-token
npm install
# launch step by step to get refreshToken
node src/dropbox_refresh_token.js
# follow steps
#
# or to check if a token is valid
node src/dropbox_is_token_valid.js
provided by Repobeats