How to retreive / download content of a shered oneDrive in SharePoint url

  api, onedrive, php, sharepoint

I am trying to retrieve the contents of shared Onedrive folders on Sharepoint sites for clients.
In php with Guzzle I call the OneDrive api and the user token:{TOKEN}/root?expand=children

then I retrieve the content like this:

$token = "****";
$url = preg_replace("/{TOKEN}/", $token, "{TOKEN}/root?expand=children");

try {
    $res = $client->request("GET", $url, ["headers" => ["Content-Type" => "application/json"]]);
  } catch (ClientException $exception) {
    return null;

$decoded = json_decode($res->getBody()->getContents(), true);

But I don’t know how to do it with sharePoint url like:


I have the client_id and secret but can’t find a solution.
I’m looking for a complete example if it’s possible.

Source: Ask PHP