msyk/dropbox-api-shortlivedtoken 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

msyk/dropbox-api-shortlivedtoken

最新稳定版本:5

Composer 安装命令:

composer require msyk/dropbox-api-shortlivedtoken

包简介

Sample implementation of generating access token from refresh token.

README 文档

README

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

by Masayuki Nii (nii@msyk.net)

The '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

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

Thanks for the creators and committers of 'spatie/dropbox-api'.

统计信息

  • 总下载量: 29.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-08