Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUESTION: Falling at the first hurdle - connection error? PHP Fatal error: Uncaught Office365\Runtime\Http\RequestException #341

Open
jj63systems opened this issue Feb 25, 2024 · 0 comments
Labels

Comments

@jj63systems
Copy link

Hi I am basically copying the examples from the README and this is my code

<?php

require_once 'vendor/autoload.php';

use Office365\Runtime\Auth\ClientCredential;
use Office365\SharePoint\ClientContext;


$credentials = new ClientCredential("{client_id}", "{client_secret}");
$client = (new ClientContext("https://{site}.sharepoint.com/"))->withCredentials($credentials);

$items = $client->getWeb()
                ->getLists()
                ->getByTitle("{list-title}")
                ->getItems()
                ->get()
                ->executeQuery();
/** @var ListItem $item */
foreach($items as $item) {
    print "Task: {$item->getProperty('Title')}\r\n";
}


I am a bit of a novice. I had tried previously to use the example code using the site / username / password example and was hitting an error thrown within SamlTokenProvider so I thought I'd try the client_id/ secret method - the code for which we see above.

When I used an invalid secret I got the message

Fatal error: Uncaught Exception: AADSTS7000215: Invalid client secret provided.

which to me is very encouraging. When I provide the correct secret I get this message:

PHP Fatal error:  Uncaught Office365\Runtime\Http\RequestException in /Users/myuser/code/scratch/croydon/vendor/vgrem/php-spo/src/Runtime/ClientRequest.php:137
Stack trace:
#0 /Users/myuser/code/scratch/croydon/vendor/vgrem/php-spo/src/Runtime/ClientRequest.php(102): Office365\Runtime\ClientRequest->validate(Object(Office365\Runtime\Http\Response))
#1 /Users/myuser/code/scratch/croydon/vendor/vgrem/php-spo/src/Runtime/OData/ODataRequest.php(128): Office365\Runtime\ClientRequest->executeQueryDirect(Object(Office365\Runtime\Http\RequestOptions))
#2 /Users/myuser/code/scratch/croydon/vendor/vgrem/php-spo/src/Runtime/ClientRequest.php(83): Office365\Runtime\OData\ODataRequest->executeQueryDirect(Object(Office365\Runtime\Http\RequestOptions))
#3 /Users/myuser/code/scratch/croydon/vendor/vgrem/php-spo/src/Runtime/ClientRuntimeContext.php(81): Office365\Runtime\ClientRequest->executeQuery(Object(Office365\Runtime\Actions\ReadEntityQuery))
#4 /Users/myuser/code/scratch/croydon/vendor/vgrem/php-spo/src/Runtime/ClientObject.php(99): Office365\Runtime\ClientRuntimeContext->executeQuery()
#5 /Users/myuser/code/scratch/croydon/sp4.php(26): Office365\Runtime\ClientObject->executeQuery()
#6 {main}
  thrown in /Users/myuser/code/scratch/croydon/vendor/vgrem/php-spo/src/Runtime/ClientRequest.php on line 137 

I am perplexed - is this an issue with this package, me or the config of my Sharepoint infrastructure (using by the way Office 365 - all cloud based).

@vgrem vgrem added the question label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants