Github Actions Workflows 上传 Dropbox

一、注册

  • 如果想免费使用,一定要选择 “继续使用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"
        }

        四、保存相关信息

        1. DROPBOX_APP_KEY: app key
        2. DROPBOX_APP_SECRET: app secret
        3. DROPBOX_REFRESH_TOKEN: refresh token

        五、使用 Lewuathe/dropbox-github-action 上传

              - name: Upload file to Dropbox
                uses: Lewuathe/dropbox-github-action@v1.0.3
                with:
                  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-file
                  target-path: /path/target-file
                  write-mode:  "overwrite"

        评论
        添加红包

        请填写红包祝福语或标题

        红包个数最小为10个

        红包金额最低5元

        当前余额3.43前往充值 >
        需支付:10.00
        成就一亿技术人!
        领取后你会自动成为博主和红包主的粉丝 规则
        hope_wisdom
        发出的红包
        实付
        使用余额支付
        点击重新获取
        扫码支付
        钱包余额 0

        抵扣说明:

        1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
        2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

        余额充值