phpSPO
phpSPO copied to clipboard
Undefined index: token_type
Hello and thank you for this library. I'm just trying a basic connect:
use Office365\Runtime\Auth\ClientCredential; use Office365\SharePoint\ClientContext; $credentials = new ClientCredential('ID', 'KEY'); $client = (new ClientContext("https://SITE.sharepoint.com"))->withCredentials($credentials);
$web = $client->getWeb(); $list = $web->getLists()->getByTitle("{list-title}"); //init List resource $items = $list->getItems(); //prepare a query to retrieve from the $client->load($items); //save a query to retrieve list items from the server $client->executeQuery(); //submit query to SharePoint server foreach($items as $item) { print "Task: {$item->getProperty('Title')}\r\n"; }
And I'm getting:
Undefined index: token_type
The stack trace shows me the issue lies with the following method:
protected function ensureAuthorizationHeader(RequestOptions $options) { $value = $this->accessToken['token_type'] . ' ' . $this->accessToken['access_token']; $options->ensureHeader('Authorization', $value); }
Seems to be the query causing the error to trigger: $client->executeQuery()
Would anyone have any ideas? Am I forgetting something? Many thanks for the help.
@teamayu A possible issue could be your client secret keys are expired.
@vgrem Should we implement an exception for this case?
Hello @teamayu, @vgrem,
Did you find a solution ? I've got the same error for create a sharepoint list.
Thanks for your answers,
Have a nice day !
I just use the MS graph API and that works fine.
Okay thanks you
Hello, Any news about this ? have the same error. @teamayu can we use MS Graph in an App-Only access context ? Thanks !