伙计们,我已经无计可施了!我正在try 访问共享文件夹,收到以下错误:
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
`GET https://graph.microsoft.com/v1.0/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL2Yvcy
FBdHVBTV9OYWN3VmFoaUZwdU1HU19CaVFDd1d1/root?expand=children` resulted in a
`403 Forbidden` response:
{"error":{"code":"accessDenied","message":"The
sharing link no longer exists, or you do not have permission to access
it."
,"innerError":{"date":"2023-10-11T05:01:49","request-id":"27bd1fc1-
74f8-4d8d-9a43-41a3aa6a9f02","client-request-id":"27bd1fc1-74f8-4d8d-9a43
-41a3aa6a9f02"}}}
分享来自这StackOverflow Question,如果你点击链接,它是非常可分享的,可以通过浏览器访问,所以does exist,所以这不是缺乏访问的问题,只是因为某种原因我的申请被拒绝了.
通常情况下,这将与没有正确的权限相关联,但令牌显示权限是access token
的一部分,此处:
"appid": "563e2470-8b86-48dc-9050-20228336584e",
"appidacr": "1",
"idp": "https://sts.windows.net/74162350-5947-4628-892f-4ee1d28d88cc/",
"idtyp": "app",
"oid": "d9b6b299-ddc2-4708-ac87-2a48beb896f4",
"rh": "0.AUIAUCMWdEdZKEaJL07h0o2IzAMAAAAAAAAAwAAAAAAAAACkAAA.",
"roles": [
"Application.ReadWrite.All",
"Sites.Read.All",
"Application.Read.All"
],
"sub": "d9b6b299-ddc2-4708-ac87-2a48beb896f4",
"tenant_region_scope": "OC",
"tid": "74162350-5947-4628-892f-4ee1d28d88cc",
"uti": "rJQ_ra77J0ux9XBeCvMIAA",
"ver": "1.0",
"wids": [
"0997a1d0-0d1d-4acb-b408-d5ca73121e90"
],
并且访问共享的代码段是(在->execute
失败):
$guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/v2.0/token';
/*
* If the client requests scope=https://graph.microsoft.com/.default, no consent prompt is shown, regardless of the contents of the client application's registered permissions for Microsoft Graph. The returned token contains the scopes Mail.Read and User.Read.
*/
$token = json_decode($guzzle->post($url, [
'form_params' => [
'client_id' => $clientId,
'scope' => 'https://graph.microsoft.com/.default',
'grant_type' => 'client_credentials',
'client_secret' => $clientSecret,
],
])->getBody()->getContents());
$accessToken = $token->access_token;
$graph = new Graph();
$graph->setAccessToken($accessToken);
$user = $graph->createRequest("GET", "/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL2YvcyFBdHVBTV9OYWN3VmFoaUZwdU1HU19CaVFDd1d1/root?expand=children")
->setReturnType(Microsoft\Graph\Model\DriveItem::class)
->execute();