回调鉴权
Last updated
2023-07-12 09:58:31
{"value":"# \u6982\u8ff0\n\n\u5ba2\u6237\u4e0a\u4f20\u6587\u4ef6\u5230\u79c1\u6709\u4e91\u5b58\u50a8\u540e\uff0c\u79c1\u6709\u4e91\u5b58\u50a8\u670d\u52a1\u5668\u4f1a\u54cd\u5e94 200 \u72b6\u6001\u7801\uff0c\u54cd\u5e94\u5185\u5bb9\u5305\u62ec hash \u548c key \u3002\u4f46\u662f\u5982\u679c\u5ba2\u6237\u9700\u8981\u81ea\u5b9a\u4e49\u54cd\u5e94\u5185\u5bb9\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u56de\u8c03\u6765\u5b9e\u73b0\u3002\n\n# \u56de\u8c03\u5b9e\u73b0\n\n\u5ba2\u6237\u7aef\u9700\u8981\u5728\u4e0a\u4f20 token \u4e2d\u8bbe\u7f6e `callbackurl` \u548c `callbody`\n\n1\u3001`callbackurl` \u5fc5\u987b\u662f\u516c\u7f51\u4e0a\u53ef\u6b63\u5e38\u8fdb\u884c POST \u8bf7\u6c42\u5e76\u80fd\u6b63\u5e38\u54cd\u5e94\u7684 url\uff0c\u5e76\u4e14\u4e1a\u52a1\u670d\u52a1\u5668\u8fd4\u56de\u7ed9\u79c1\u6709\u4e91\u5b58\u50a8\u7684\u5185\u5bb9\u5fc5\u987b\u662f json \u4e32.\n\n\u8fd9\u91cc\u7ed9\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u80fd\u54cd\u5e94200\u7684php\u4ee3\u7801(\u83b7\u53d6 `callbackbody` \u5e76\u6253\u5370\u4e00\u4e2a\u5b57\u7b26\u4e32\u7ed9\u5ba2\u6237\u7aef)\n\n![](https:\/\/tp2lravq.hk03.1112oss.com\/202307120954097jndujis19p1cgpd4k8f9ju7d5hev8lw.png)\n2\u3001`callbackbody` \u662f\u9700\u8981\u5411\u4e1a\u52a1\u670d\u52a1\u5668\u53d1\u9001\u7684\u56de\u8c03\u5185\u5bb9\uff0c\u9700\u4f7f\u7528\u79c1\u6709\u4e91\u5b58\u50a8\u7684\u9b54\u6cd5\u53d8\u91cf\u6216\u81ea\u5b9a\u4e49\u53d8\u91cf\u6765\u586b\u5145\u3002 \u4f46\u662f\u683c\u5f0f\u4e00\u5b9a\u8981\u6b63\u786e\uff0c\u5426\u5219\u4f1a\u62a5400\u683c\u5f0f\u9519\u8bef.\n\n\u4f8b\u5982 java \u4e2d\u6b63\u786e\u7684\u683c\u5f0f\uff1a\n\n```\nauth.uploadToken(bucket,key,3600,new StringMap() \n.put(\"callbackUrl\",\"callbackurl\") \n.put(\"callbackBody\", \"{\"filename\":$(fname),\"filesize\":$(fsize),\"width\":$(imageInfo.width)}\") );\n```\n\n3\u3001`callbodytype` \u9ed8\u8ba4\u662f `application\/x-www-form-urlencoded`, \u4e5f\u53ef\u5728\u4e0a\u4f20\u7b56\u7565\u4e2d\u8bbe\u7f6e\u4e3a `application\/json`\n\n# \u56de\u8c03\u9274\u6743\n\n\u56e0\u4e3a\u56de\u8c03\u5730\u5740\u662f\u516c\u7f51\u53ef\u8bbf\u95ee\u7684\uff0c\u4efb\u4f55\u4e00\u53f0\u670d\u52a1\u5668\u90fd\u53ef\u4ee5\u5bf9\u5176\u53d1\u8d77\u56de\u8c03\uff0c\u5982\u4f55\u786e\u8ba4\u56de\u8c03\u662f\u6765\u81ea\u79c1\u6709\u4e91\u5b58\u50a8\u7684\u5462\uff1f\n\n\u79c1\u6709\u4e91\u5b58\u50a8\u5728\u53d1\u8d77\u56de\u8c03\u8bf7\u6c42\u65f6\u4f1a\u5728\u8bf7\u6c42\u5934\u4e2d\u5e26\u4e0a `Authorization` \u5b57\u6bb5\uff0c\n\n```\nAuthorization:QBox iN7NgwM31j4-BZacMjPrOQBs34UG1maYCAQmhdCV:tDK-3f5xF3SJYEAwsll5g=\n```\n\n\u5176\u4e2d QBox \u4e3a\u56fa\u5b9a\u503c\uff0ciN7Ngw...dCV \u4e3a\u7528\u6237\u7684 Accesskey\uff0ctDK-3f...5g= \u4e3a\u7b7e\u540d\u7ed3\u679c encoded_data\u3002\n\u56e0\u4e3a\u56de\u8c03\u5730\u5740\u662f\u516c\u7f51\u53ef\u8bbf\u95ee\u7684\uff0c\u4efb\u4f55\u4e00\u53f0\u670d\u52a1\u5668\u90fd\u53ef\u4ee5\u5bf9\u5176\u53d1\u8d77\u56de\u8c03\uff0c\u5982\u4f55\u786e\u8ba4\u56de\u8c03\u662f\u6765\u81ea\u79c1\u6709\u4e91\u5b58\u50a8\u7684\u5462\uff1f\n\n\u79c1\u6709\u4e91\u5b58\u50a8\u5728\u53d1\u8d77\u56de\u8c03\u8bf7\u6c42\u65f6\u4f1a\u5728\u8bf7\u6c42\u5934\u4e2d\u5e26\u4e0a `Authorization` \u5b57\u6bb5\uff0c\n\n```\nAuthorization:QBox iN7NgwM31j4-BZacMjPrOQBs34UG1maYCAQmhdCV:tDK-3f5xF3SJYEAwsll5g=\n```\n\n\u5176\u4e2d QBox \u4e3a\u56fa\u5b9a\u503c\uff0ciN7Ngw...dCV \u4e3a\u7528\u6237\u7684 Accesskey\uff0ctDK-3f...5g= \u4e3a\u7b7e\u540d\u7ed3\u679c encoded_data\u3002\n\n\u4e1a\u52a1\u670d\u52a1\u5668\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u6765\u5bf9\u5176\u8fdb\u884c\u9a8c\u8bc1\uff0c \u4f8b\u5982\u5982\u4e0b\u9762\u7684\u4ee3\u7801php\u6765\u8fdb\u884c\u9a8c\u8bc1\uff1a\n\n![](https:\/\/tp2lravq.hk03.1112oss.com\/20230712095745qs7ls2fr3giiv99gmkeu11bipuvrbou1.png)\n# \u56de\u8c03\u5e38\u89c1\u9519\u8bef\n\n## 1\u3001400\u9519\u8bef\n\n\u8fd9\u4e2a\u662f\u4e0a\u4f20\u65f6\u8868\u5355\u683c\u5f0f\u9519\u8bef\uff0c\u4f8b\u5982 `callbackbody` \u8bbe\u7f6e\u7684\u683c\u5f0f\u6709\u95ee\u9898\u7b49\n\n## 2\u3001579\u9519\u8bef\n\n1\u3001\u4e0a\u4f20\u6210\u529f\u56de\u8c03\u5931\u8d25\uff0c\u53ef\u4ee5\u81ea\u5df1\u5148\u7528curl\u6765\u9a8c\u8bc1callbackurl\u662f\u5426\u80fd\u6210\u529f\u54cd\u5e94200\n\n```\ncurl -X POST -d \"name=123.jpg\" http:\/\/url\n```\n\n2\u3001\u4e1a\u52a1\u670d\u52a1\u5668\u8fd4\u56de\u7ed9\u79c1\u6709\u4e91\u5b58\u50a8\u7684 body \u4e0d\u662f\u5408\u6cd5\u7684 json \u4e32 \u62a5\u9519\u4fe1\u606f\uff1a`{\"error\":\"unexcepted response\"}`\n\u8fd9\u65f6\u53ef\u901a\u8fc7\u6293\u5305\uff0c\u83b7\u53d6\u79c1\u6709\u4e91\u5b58\u50a8\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u7684 body \uff0c\u901a\u8fc7 [http:\/\/jsonlint.com](http:\/\/jsonlint.com\/) \u9a8c\u8bc1\u662f\u5426\u56de\u8c03\u7684 body \u4e3a\u5408\u6cd5\u7684 json \u4e32\n\n3\u3001\u4e1a\u52a1\u670d\u52a1\u5668\u62d2\u7edd\u79c1\u6709\u4e91\u5b58\u50a8\u7684\u56de\u8c03\u8bf7\u6c42 \u89e3\u51b3\u65b9\u6848\u662f\u914d\u7f6e\u5141\u8bb8\u79c1\u6709\u4e91\u5b58\u50a8\u7684\u56de\u8c03UA\u7684\u8bbf\u95ee\u3002 \u79c1\u6709\u4e91\u5b58\u50a8\u56de\u8c03UA\uff1aqiniu-callback\/1.0"}