一、获取Access Token示例
1. 请您将以下HTTP请求直接粘贴到浏览器地址栏内,并按下回车键。
https://openapi.baidu.com/oauth/2.0/authorize?response_type=token&client_id=L6g70tBRRIXLsY0Z3HwKqlRE&redirect_uri=oob&scope=netdisk
2、执行后,弹出百度登录页面,登录后弹出以下授权页面:
3、授权后,将跳转到以下百度OAuth2.0页面:
4、请将此页面地址栏的内容拷贝出来,您将看到: http://openapi.baidu.com/oauth/2.0/login_success#expires_in=2592000&access_token=3.811a254908d094012df764a38882a179.2592000.1348661720.2233553628-238347&session_secret=9deaa587f9cd177f02079506dc4391ab&session_key=94rrnl7qf2cYVnSZ0KfARwLS%2BIMuQn%2FbZKgbYBEnwDZv1O%2Bzp7fJxo8cN%2BrrhLAQsJy8FeBD2SP6Ioux%2B2TW6IgR8JFIGsU%3D&scope=basic+netdisk
说明:红色字就是access_token。
二、上传文件测试
curl -k -L -F "file=@/usr/local/dbbak/dsideal_db-2015-11-21=03:00:02.sql.gz" "https://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&access_token=<your_access_token>&path=/apps/pcstest_oauth/test/data.gz"
说明:上传文件必须在/apps/pcstest_oauth/目录下。
三、其他说明文档
#获取token
说明文档:http://developer.baidu.com/wiki/index.php?title=docs/pcs/guide/usage_example
#获取token地址
https://openapi.baidu.com/oauth/2.0/authorize?response_type=token&client_id=L6g70tBRRIXLsY0Z3HwKqlRE&redirect_uri=oob&scope=netdisk
#从地址栏中粘出access_token
access_token=23.d72bff6b9eccb230356267c2a01f8bfd.2592000.1451093998.1829018343-238347
============================================================================================
#上传文件测试
curl -k -L -F "file=@/usr/local/dbbak/dsideal_db-2015-11-21=03:00:02.sql.gz" "https://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&access_token=23.c55ce5b45ca4b4b478a34aacbf78fb70.2592000.1451091550.1829018343-238347&path=/apps/pcstest_oauth/test/data.gz"
说明文档:http://developer.baidu.com/wiki/index.php?title=docs/pcs/rest/file_data_apis_list
============================================================================================
其他文档:http://my.oschina.net/bygreencn/blog/193838
============================================================================================