I am currently trying to develop a PHP application that checks whether or not a folder exists in a SharePoint directory. While I have managed to submit the right REST requests when logged in inside the browser, my problem is authenticating using URL.

There are a two requirements to this:

  1. I do not have Admin access to our SharePoint subscription so I cannot register apps
  2. I can only use an existing user account and authenticate with email/password.

I have found several tutorials and even thybag's PHP library for SharePoint. None of these things work and I assume there has been a change in the authentication method. I am still able to get the Binary Token from Microsoft's Server but sending it to the SharePoint server doesn't work.

Is there a way to solve this problem?

2 Answers 2


Both phpSPO and PHP-SharePoint-Lists-API (see SharePointOnlineAuth.php) libraries support claims-based authentication for SharePoint Online.

The following diagram illustrates how active authentication to SharePoint Online (SPO) is performed

enter image description here


client.signIn (username, password)

The signin method performs a claims-based authentication:

  • build a SAML request (using SAML.xml template included in module)
  • submit a SAML token request to Microsoft Online Security Token Service
  • receive a signed security token
  • POST the token to SharePoint Online
  • receive FedAuth and rtFa authentication cookies
  • store the cookies in client for use in subsequent requests


try {
    $client = new SPOClient($url);
    echo 'You have authenticated successfully\n';
catch (Exception $e) {
    echo 'Connection failed: ',  $e->getMessage(), "\n";

Disclaimer: i'm the author of phpSPO library


You can use this library



require_once 'SPOClient.php';

$username = '[email protected]';
$password = 'password';
$url = "https://domain.sharepoint.com/";

$client = new SPOClient($url);

  • 1
    This library does essentially the same thing as Thybag's library. My problem is the authentication URL (/_forms/default.aspx?wa=wsignin1.0). This always returns a redirect to the new login.microsoftonline.com. This doesn't seem to support authentication via BinaryToken.
    – Jan
    Jan 1, 2015 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.