管理凭证
Last updated
2023-07-11 15:58:29
{"value":"\u8d44\u6e90\u7ba1\u7406\u5c5e\u4e8e\u654f\u611f\u7684\u64cd\u4f5c\uff0c\u539f\u5219\u4e0a\u6240\u6709\u8d44\u6e90\u7ba1\u7406\u64cd\u4f5c\u5747\u5e94\u5728\u4e1a\u52a1\u670d\u52a1\u7aef\u8fdb\u884c\u3002\u5173\u4e8e\u7ba1\u7406\u914d\u7f6e\uff0c\u79c1\u6709\u4e91\u5b58\u50a8\u652f\u6301\u7684\u670d\u52a1\u7aef\u8bed\u8a00 SDK \u90fd\u5df2\u7ecf\u5c01\u88c5\u597d\uff0c\u4f8b\u5982\u8d44\u6e90\u5220\u9664\u3001\u79fb\u52a8\u548c\u590d\u5236\u7b49\u64cd\u4f5c\u53ea\u9700\u8c03\u7528\u76f8\u5e94\u7684\u65b9\u6cd5\u5373\u53ef\uff0c\u4e0d\u9700\u8981\u624b\u52a8\u751f\u6210\u7ba1\u7406\u914d\u7f6e\u7684\u53d1\u9001\u8bf7\u6c42\u3002\u5404 SDK \u7684\u5bf9\u5e94\u5165\u53e3\u5982\u4e0b\uff1a\n\n\u00b7 [Java](https:\/\/github.com\/CDNCloudForU\/java-sdk)\n\u00b7 [Python](https:\/\/github.com\/CDNCloudForU\/python-sdk)\n\u00b7 [PHP](https:\/\/github.com\/CDNCloudForU\/php-sdk)\n\u00b7 [Go](https:\/\/github.com\/CDNCloudForU\/api.v7)\n\u00b7 [Android](https:\/\/github.com\/CDNCloudForU\/android-sdk)\n\u00b7 [iOS](https:\/\/github.com\/CDNCloudForU\/objc-sdk)\n\u00b7 [Node.js](https:\/\/github.com\/CDNCloudForU\/nodejs-sdk)\n\u00b7 [JavaScript](https:\/\/github.com\/CDNCloudForU\/js-sdk)\n\u00b7 [C\/C++](https:\/\/github.com\/CDNCloudForU\/c-sdk\/releases)\n\u00b7 [C#](https:\/\/github.com\/CDNCloudForU\/csharp-sdk)\n\n\u6bcf\u4e00\u4e2a\u8d44\u6e90\u7ba1\u7406\u8bf7\u6c42\u5747\u9700\u5728 HTTP \u8bf7\u6c42\u5934\u90e8\u589e\u52a0\u4e00\u4e2a Authorization \u5b57\u6bb5\uff0c\u5176\u503c\u4e3a\u7b26\u5408\u7ba1\u7406\u51ed\u8bc1\u7684\u5b57\u7b26\u4e32\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a\n\n![](https:\/\/tp2lravq.hk03.1112oss.com\/20230711155747wqknjt56m9b0o4r4sjuu8h63neb25t4h.png)\n\n\u6ce8\u610f\uff1a `EncodedEntryURI` \u7684\u7ec6\u8282\u8bf7\u53c2\u8003 \u6570\u636e\u683c\u5f0f\n\n\u7ba1\u7406\u51ed\u8bc1\u662f\u79c1\u6709\u4e91\u5b58\u50a8\u7528\u4e8e\u9a8c\u8bc1\u7ba1\u7406\u8bf7\u6c42\u662f\u5426\u5408\u6cd5\u7684\u673a\u5236\uff0c\u5efa\u8bae\u5728\u4e1a\u52a1\u670d\u52a1\u5668\u7aef\u4f7f\u7528\u3002\u4f8b\u5982\u67e5\u770b\u8d44\u6e90\u5143\u4fe1\u606f\u3001\u5220\u9664\u6216\u79fb\u52a8\u8d44\u6e90\u7b49\uff0c\u901a\u5e38\u9700\u8981\u5e26\u4e00\u4e2a\u5408\u6cd5\u7684\u7ba1\u7406\u51ed\u8bc1\u3002\u4e0d\u5e26\u51ed\u8bc1\u6216\u5e26\u975e\u6cd5\u51ed\u8bc1\u7684\u7ba1\u7406\u8bf7\u6c42\u5c06\u8fd4\u56de HTTP \u9519\u8bef\u7801 401\uff0c\u4ee3\u8868\u8ba4\u8bc1\u5931\u8d25\u3002\u7ba1\u7406\u51ed\u8bc1\u7684\u4f5c\u7528\u4e0e\u4e0b\u8f7d\u51ed\u8bc1\u7c7b\u4f3c\uff1a\n\n- \u4fdd\u8bc1\u8bf7\u6c42\u53d1\u8d77\u8005\u62e5\u6709\u5bf9\u76ee\u6807\u7a7a\u95f4\u7684\u7ba1\u7406\u6743\u9650\u3002\n- \u4fdd\u8bc1\u670d\u52a1\u7aef\u6536\u5230\u7684\u7ba1\u7406\u8bf7\u6c42\u5185\u5bb9\u672a\u7ecf\u4e2d\u9014\u7be1\u6539\uff0c\u5177\u4f53\u5305\u62ec\u4ee3\u8868\u7ba1\u7406\u52a8\u4f5c\u7684 URI \u548c\u8be5\u7ba1\u7406\u52a8\u4f5c\u7684\u53c2\u6570\u4fe1\u606f\u5747\u5e94\u672a\u53d7\u5230\u7be1\u6539\u3002\n\n\n\n# \u7b97\u6cd5\n\n1.\u751f\u6210\u5f85\u7b7e\u540d\u7684\u539f\u59cb\u5b57\u7b26\u4e32\uff1a\n\u539f\u59cb\u5b57\u7b26\u4e32\u7531\u8bf7\u6c42req\u7684Method\u3001Path\u3001query\u3001Host\u3001Header\u548c\u8bf7\u6c42\u7684Body\u6309\u7167\u4ee5\u4e0b\u683c\u5f0f\u7ec4\u6210(\u62ec\u53f7\u53ca\u4e2d\u6587\u4ec5\u8868\u793a\u6ce8\u91ca\uff0c\u6bd4\u5982\u201c\uff08\u7a7a\u683c\uff09\u201d)\n\n```\nsigningStr=req.Method\uff08HTTP\u534f\u8bae\u7684Method\u662f\u5927\u5c0f\u5199\u654f\u611f\u7684\uff09 + \" \"\uff08\u7a7a\u683c\uff09 +req.Path\n\u5982\u679cquery\u4e3a\u975e\u7a7a\u5b57\u7b26\u4e32(query\u4e0d\u5305\u542b\u95ee\u53f7(?)\u5b57\u7b26)\nsigningStr=req.Method + \" \"\uff08\u7a7a\u683c\uff09 +req.Path+?(\u82f1\u6587\u95ee\u53f7)+req.query\n\n\u63a5\u4e0b\u6765\u589e\u52a0Host\u4fe1\u606f\nsigningStr=signingStr+\\n(\u6362\u884c\u7b26)Host:(\u82f1\u6587\u7b26\u53f7\u5192\u53f7) \uff08\u7a7a\u683c\uff09+req.Host\n\n\u5982\u679c\u60a8\u8bbe\u7f6e\u4e86Content-Type\u7684 Header,\u4e5f\u9700\u8981\u6dfb\u52a0\nsigningStr=signingStr+\\n(\u6362\u884c\u7b26)Content-Type:(\u82f1\u6587\u7b26\u53f7\u5192\u53f7) (\u7a7a\u683c)+req.Content-Type\n\n\u5bf9\u4e8e\u4e03\u725b\u7279\u6b8a\u7684X-Qiniu-<key>\u5934\u4fe1\u606f\uff0c\u5982\u679c\u6709\u4e5f\u9700\u8981\u6dfb\u52a0\uff0c \u201dX-Qiniu-<key>\u201cheader\u662f\u6307\u5728\u8bf7\u6c42Header\u4e2d\u4ee5\u201cX-Qiniu-\u201d\u5b57\u7b26\u4e32\u5f00\u5934\u7684\u5934\u90e8\u4fe1\u606f\u5bf9,\u4e3a\u4e03\u725b\u670d\u52a1\u7aef\u7406\u89e3\u3002\u5176\u4e2dkey\u4e0d\u53ef\u4e3a\u7a7a\u5b57\u7b26\u3002\u5728\u751f\u6210\u7b7e\u540d\u7b97\u6cd5\u4e2d\u5bf9key\u6709\u4e00\u5b9a\u7684\u683c\u5f0f\u8f6c\u6362\u8981\u6c42\uff0c\u7b2c\u4e00\u4e2a\u5b57\u6bcd\u548c\u8fde\u5b57\u7b26\uff08-\uff09\u540e\u9762\u7684\u5b57\u6bcd\u5927\u5199\uff0c\u5176\u4f59\u5b57\u6bcd\u90fd\u662f\u5c0f\u5199\u3002\u6ee1\u8db3\u4ee5\u4e0a\u6761\u4ef6\u7684\u952e\u503c\u5bf9\uff0c\u6839\u636e<key>\u5b57\u7b26\u4e32 ASCII\u5927\u5c0f\u6392\u5e8f\u540e\uff0c\u7531\u5c0f\u5230\u5927\uff0c\u4f9d\u6b21\u52a0\u5165\u5f85\u7b7e\u540d\u5b57\u7b26\u4e32\nsigningStr=signingStr+\\n(\u6362\u884c\u7b26)+<key1>:(\u82f1\u6587\u7b26\u53f7\u5192\u53f7) (\u7a7a\u683c)+<value1>+\\n(\u6362\u884c\u7b26)+<key2>:(\u82f1\u6587\u7b26\u53f7\u5192\u53f7) (\u7a7a\u683c)+<value2>+...\n\n\u5b8c\u6210\u4ee5\u4e0a\u4fe1\u606f\u4e4b\u540e\u52a0\u51652\u4e2a\u8fde\u7eed\u5bf9\u6362\u884c\u7b26\nsigningStr=signingStr+\\n(\u6362\u884c\u7b26)+\\n(\u6362\u884c\u7b26)\n\n\u5982\u679c\u60a8\u8bbe\u7f6e\u4e86\u8bf7\u6c42Body\uff0c\u5e76\u4e14\u8bbe\u7f6eContent-Type\u4e0d\u4e3a\"application\/octet-stream\"\u7c7b\u578b\uff0cBody\u4e5f\u9700\u8981\u52a0\u5165\u5f85\u7b7e\u540d\u5b57\u7b26\u4e32\nsigningStr=signingStr+<body>\n```\n\n2.\u4f7f\u7528SecertKey\u5bf9\u4e0a\u4e00\u6b65\u751f\u6210\u7684\u539f\u59cb\u5b57\u7b26\u4e32\u8ba1\u7b97HMAC-SHA1\u7b7e\u540d\uff1a\n\n```\nsign = hmac_sha1(signingStr, \"<SecretKey>\")\n```\n\n3.\u5bf9\u7b7e\u540d\u8fdb\u884cURL \u5b89\u5168\u7684 Base64 \u7f16\u7801\uff1a\n\n```\nencodedSign = urlsafe_base64_encode(sign)\n```\n\n4.\u5c06 AccessKey \u548c encodedSign \u7528\u82f1\u6587\u7b26\u53f7 : \u8fde\u63a5\u8d77\u6765\uff1a\n\n```\naccessToken = \"<AccessKey>:<encodedSign>\"\n```\n\n\n\n# \u793a\u4f8b\n```\n# \u5047\u8bbe\u6709\u5982\u4e0b\u7684\u7ba1\u7406\u8bf7\u6c42\uff1a \nAccessKey = \"MY_ACCESS_KEY\"\nSecretKey = \"MY_SECRET_KEY\"\nurl = \"http:\/\/rs-qos.pocdemo.qiniu.io\/move\/bmV3ZG9jczpmaW5kX21hbi50eHQ=\/bmV3ZG9jczpmaW5kLm1hbi50eHQ=\"\nmethod = \"POST\"\n\n#\u5219\u5f85\u7b7e\u540d\u7684\u539f\u59cb\u5b57\u7b26\u4e32\u662f\uff1a\nsigningStr = \"POST \/move\/bmV3ZG9jczpmaW5kX21hbi50eHQ=\/bmV3ZG9jczpmaW5kLm1hbi50eHQ=\\nHost: rs-qos.pocdemo.qiniu.io\\n\\n\"\n\n#\u7b7e\u540d\u5b57\u7b26\u4e32\u662f\uff1a \nsign = \"d6e2efb9933a97aa02cd916a909ea8238a053154\"\n\u6ce8\u610f\uff1a\u7b7e\u540d\u7ed3\u679c\u662f\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u6b64\u5904\u8f93\u51fa\u7684\u662f\u6bcf\u4e2a\u5b57\u8282\u7684\u5341\u516d\u8fdb\u5236\u8868\u793a\uff0c\u4ee5\u4fbf\u6838\u5bf9\u68c0\u67e5\u3002\n\n#\u7f16\u7801\u540e\u7684\u7b7e\u540d\u5b57\u7b26\u4e32\u662f\uff1a\nencodedSign = \"1uLvuZM6l6oCzZFqkJ6oI4oFMVQ=\"\n\n#\u6700\u7ec8\u7684\u7ba1\u7406\u51ed\u8bc1\u662f\uff1a \naccessToken = \"MY_ACCESS_KEY:1uLvuZM6l6oCzZFqkJ6oI4oFMVQ=\"\n```"}