PHPackages                             msyk/dropbox-api-shortlivedtoken - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. msyk/dropbox-api-shortlivedtoken

ActiveApplication[Authentication &amp; Authorization](/categories/authentication)

msyk/dropbox-api-shortlivedtoken
================================

Sample implementation of generating access token from refresh token.

5(3y ago)032.8k↓48.3%11MITPHPPHP &gt;=7.1.0

Since Jul 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/msyk/dropbox-api-shortlivedtoken)[ Packagist](https://packagist.org/packages/msyk/dropbox-api-shortlivedtoken)[ Docs](https://github.com/msyk/)[ RSS](/packages/msyk-dropbox-api-shortlivedtoken/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (1)

dropbox-api-shortlivedtoken
===========================

[](#dropbox-api-shortlivedtoken)

Sample implementation of generating access token from refresh token with spatie/dropbox-api.

by Masayuki Nii ()

The ['spatie/dropbox-api'](https://github.com/spatie/dropbox-api) is one of the PHP library for Dropbox API. The access token for authentication was just simple, but at mid-2021 it was changed. The access token terns to deactivate in short-lived period, and we have to regenerate it from the refresh token periodically. The refreshing feature is not implemented on 'spatie/dropbox-api' because it's not scope of the library from the descriptions on discussion board. This repository is the sample implementation of refreshing access tokens. In the readme page of 'spatie/dropbox-api' describes about AutoRefreshingDropBoxTokenService class, and here is the example of AutoRefreshingDropBoxTokenService class.

How to try here
---------------

[](#how-to-try-here)

- Create Dropbox App on the Dropbox App Console. ()
- Generate refresh token. (ex. )
- `composer update`
- Copy the credential\_must\_exists.php to credentials.php and fill it. You require to set the AppKey, AppSecret, Refresh Token, and file path to store the access token.
- Do the index.php. (ex. `php -S localhost:9000` and open that url with any browser)

Integrate your solutions
------------------------

[](#integrate-your-solutions)

You can install the package via composer:

`composer require msyk/dropbox-api-shortlivedtoken`

Or you can describe in the 'require' section of the composer.json file

The operations for your Dropbox area is the same way of 'spatie/dropbox-api', as like below. The Clinet class is coming from 'spatie/dropbox-api'. The AutoRefreshingDropBoxTokenService class has 4 parameter constructor. The cached access token is going to store the path in $tokenFilePath, so it must be a writable directory and file.

```
use Spatie\Dropbox\Client;
use msyk\DropboxAPIShortLivedToken\AutoRefreshingDropBoxTokenService;
try {
    $tokenProvider = new AutoRefreshingDropBoxTokenService($refreshToken, $appKey, $appSecret, $tokenFilePath);
    $client = new Client($tokenProvider);
    $list = $client->listFolder("/");
} catch (\Exception $ex) {
    var_export($ex->getMessage()); // Very simple output.
}
var_export($list); // Very simple output.

```

Acknowledgements
----------------

[](#acknowledgements)

Thanks for the creators and committers of ['spatie/dropbox-api'](https://github.com/spatie/dropbox-api).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

1411d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f61df794063cf9e5c2565afa8296be4a556660056256e755d6a903439a994e8?d=identicon)[inter-mediator](/maintainers/inter-mediator)

---

Top Contributors

[![msyk](https://avatars.githubusercontent.com/u/182120?v=4)](https://github.com/msyk "msyk (9 commits)")

---

Tags

phpoauth2dropboxDropbox-API

### Embed Badge

![Health badge](/badges/msyk-dropbox-api-shortlivedtoken/health.svg)

```
[![Health](https://phpackages.com/badges/msyk-dropbox-api-shortlivedtoken/health.svg)](https://phpackages.com/packages/msyk-dropbox-api-shortlivedtoken)
```

###  Alternatives

[hwi/oauth-bundle

Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony.

2.4k21.5M69](/packages/hwi-oauth-bundle)[stevenmaguire/oauth2-dropbox

Dropbox OAuth 2.0 Client Provider for The PHP League OAuth2-Client

16561.4k2](/packages/stevenmaguire-oauth2-dropbox)[and/oauth

Simple and amazing OAuth library with many providers. Just try it out!

4645.2k2](/packages/and-oauth)[andalisolutions/oauth2-anaf

Anaf OAuth 2.0 support for the PHP League's OAuth 2.0 Client

194.1k](/packages/andalisolutions-oauth2-anaf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
