Github Actions Workflows 上传 Dropbox
一、注册
- 访问 https://www.dropbox.com/register
- 选择 "个人"
- 如果想免费使用,一定要选择 “继续使用2GB的Dropbox Basic 套餐”,如下:
二、在 Dropbox 中 创建app
- 需要去注册的邮箱中验证一下邮箱.
- 访问 https://www.dropbox.com/developers/apps 创建app
- 按下面的配置进行设置, Name your app 是全平台唯一的,在我们的场景中没有特别意义,所以随便起一个唯一的就好
- 在app 的 Permissions里添加权限
- 在 app 的 Settings里设置
三、生成 refresh token
- 1. 浏览器中访问下面的url,将${YOUR_APP_KEY}将成自己的app key.
https://www.dropbox.com/oauth2/authorize?client_id=${YOUR_APP_KEY}&response_type=code&token_access_type=offline
- 2. 访问后会提示
点 继续,会提示
点 允许 得到一个 authorization code(下图中的马赛克部分),下步中会用到
- 3. 使用 curl 或者 python 脚本 请求 refresh token,将 ${AUTHORIZATION_CODE}, ${YOUR_APP_KEY}, ${YOUR_APP_SECRET} 替换成对应的值。
curl https://api.dropbox.com/oauth2/token -d code=${AUTHORIZATION_CODE} -d grant_type=authorization_code -d client_id=${YOUR_APP_KEY} -d client_secret=${YOUR_APP_SECRET}
发送请求后将得到如下响应, 将 refresh_token 保存
{"access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","token_type": "bearer",..."refresh_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","account_id": "xxxxxxxxx","uid": "xxxxxxxx"
}
四、保存相关信息
- DROPBOX_APP_KEY: app key
- DROPBOX_APP_SECRET: app secret
- DROPBOX_REFRESH_TOKEN: refresh token
五、使用 Lewuathe/dropbox-github-action 上传
- name: Upload file to Dropboxuses: Lewuathe/dropbox-github-action@v1.0.3with:dropbox-app-key: ${{ secrets.DROPBOX_APP_KEY }}dropbox-app-secret: ${{ secrets.DROPBOX_APP_SECRET }}dropbox-refresh-token: ${{ secrets.DROPBOX_REFRESH_TOKEN }}source-path: /path/source-filetarget-path: /path/target-filewrite-mode: "overwrite"