本帖最后由 滑稽 于 2018-5-22 10:36 编辑
几个问题:
1. lib/onedrive.php中的authorize函数中的请求参数少了resource,需要在该函数中增加$api_url = self:api_url;并在请求参数末尾附上&resource={$api_url};
2. 世纪互联运营的office 365 authorize返回的结果是400,出错信息是- {"error":"invalid_resource","error_description":"AADSTS50001: The application named https://microsoftgraph.chinacloudapi.cn/v1.0 was not found in the tenant named ****. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.\r\nTrace ID: ****\r\nCorrelation ID: ****\r\nTimestamp: 2018-05-22 02:01:23Z","error_codes":[50001],"timestamp":"2018-05-22 02:01:23Z","trace_id":"****","correlation_id":"****"}
复制代码
3. 如果不带resource的话,世纪互联运营的office 365 authorize返回结果也是400,出错信息是- "error":"invalid_resource","error_description":"AADSTS50001: Resource identifier is not provided.
复制代码
4. lib/onedrive.php中的authorize函数中手动指定resource为00000003-0000-0ff1-ce00-000000000000,修改后函数如下:- static function authorize($code = ""){
- $client_id = self::$client_id;
- $client_secret = self::$client_secret;
- $redirect_uri = self::$redirect_uri;
- $api_url = "00000003-0000-0ff1-ce00-000000000000";
- $url = self::$oauth_url."/token";
- $post_data = "client_id={$client_id}&redirect_uri={$redirect_uri}&client_secret={$client_secret}&code={$code}&grant_type=authorization_code&resource={$api_url}";
- fetch::$headers = "Content-Type: application/x-www-form-urlencoded";
- $resp = fetch::post($url, $post_data);
- print_r($resp);
- $data = json_decode($resp->content, true);
- return $data;
- }
复制代码 可以正常完成绑定过程,能够获取到token、refresh(base.php中)和生成token.php,但无法列出文件(疑似不能正常获取到app_url,但向base.php手动添加app_url并重新刷新缓存似乎也无**常列出文件) |