type
status
date
slug
summary
tags
category
icon
password

前言

在做网盘毕设对接阿里云盘部分时,发现上传和下载操作需要传递x-deivce-idx-signature两个header,而获取token的接口并没有返回这两个参数,上网查询资料后发现需要本地进行签名操作。

用到的接口

通过refreshToken拿到临时token:https://auth.aliyundrive.com/v2/account/token
参数:grant_type refresh_token
创建和激活会话:https://api.aliyundrive.com/users/v1/users/device/create_session
参数:pubKey deviceName modelName

签名过程

  1. 生成密钥对
      • 生成随机私钥
      • 用私钥生成公钥
  1. 拼接字符串
      • appId:deviceId:userId:nonce
      • appId 和 nonce 可以固定
      • deviceId 为随机UUID
      • userId 通过拿token的接口可获取到
  1. 对字符串进行签名
      • 对拼接好的字符串进行 sha256 编码,再进行签名
      • 签名算法:ecc-secp256k1

传递参数

  • grant_type 为验证方式,输入refreshToken即可
  • pubKey 为公钥签名加 04
  • deviceName 和 modelName 为自己取的名,示例图:
    • notion image
  • x-device-id 为上面随机生成的deviceId
  • x-signature 为签名后面加 01

代码实现

参考:
 
Docker Compose环境变量传递到项目内Flex布局居中
Loading...
Kougami
Kougami
Life Will Change
统计
文章数:
18
公告
てへぺりんこ