phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

Undefined index: token_type

Open teamayu opened this issue 2 years ago • 5 comments

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 avatar Jul 06 '21 04:07 teamayu

@teamayu A possible issue could be your client secret keys are expired.

@vgrem Should we implement an exception for this case?

mahmudz avatar Aug 17 '21 10:08 mahmudz

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 !

Jedguy avatar Mar 22 '22 09:03 Jedguy

I just use the MS graph API and that works fine.

teamayu avatar Mar 22 '22 09:03 teamayu

Okay thanks you

Jedguy avatar Mar 22 '22 09:03 Jedguy

Hello, Any news about this ? have the same error. @teamayu can we use MS Graph in an App-Only access context ? Thanks !

doxt3r avatar Sep 15 '22 06:09 doxt3r