npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dropbox-refresh-token

v0.0.5

Published

provide dropbox token related tooling

Downloads

455

Readme

dropbox-refresh-token

NPM

Quickstart

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

Context : about Dropbox tokens

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:

  1. to ask an access-code for an "offline" token-access-type
    • this step require to login to allow application access.
  2. get a (long-lived) refresh-token with this access-code.

Having this refresh-token in "offline" mode (without login requirement) you could then each time needed:

  1. (day) ask (short-lived) access-token.
  2. (day+1) ask (short-lived) access-token.
  3. (day+2) ask (short-lived) access-token.
  4. (...)

About token time to live

  • "short-lived" that apply to access-code and access-token means 14400 sec (4 hours) - this ttl is provided in dropbox response when asking for this code/token.
  • "long-lived" that apply to refresh-token (seems to) means valid until revoked (src).

references

Project features

Feature for a given DropBox app (appKey, appSecret).

  • (step 1) build login url to allow application access and then retrieve short-lived access code for an "offline" token-access-type (appKey only) getShortLivedAccessCodeUrlViaLoginUrl(appKey)
  • (step 2) provide method to call Dropbox API that ask (long-lived) refresh-token from this short-lived access code (accessCode, appKey, appSecret). getRefreshToken(shortLivedAccessCode, appKey, appSecret, logToken = false)
  • (step 3++) provide method to call Dropbox API that ask a fresh (short-lived) access token from a valid refresh-token (refreshToke, appKey, appSecret). refreshAccessToken(refresh_token, appKey, appSecret, logToken = false)

HowTo use "dropbox-refresh-token" library

  • Setup this project as dependency
npm i dropbox-refresh-token
  • Integration examples
import {
    isSet, getShortLivedAccessCodeUrlViaLoginUrl, 
    getRefreshToken, refreshAccessToken
} from "dropbox-refresh-token";

import {
    isSet, getCurrentAccount, isAccessTokenValid
} from "dropbox-refresh-token";

Another example - step-by-step to retrieve Dropbox RefreshToken

<!> 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

Contributions

Repobeats

provided by Repobeats