Skip to content

Certificate authentication to sharepoint error - malformed request #360

Description

@mix1981

Hi,
I've been successfully using library using credential authentication (before it was blocked by Microsoft) and AppOnly permissions. Unfortunately, Microsoft just disabled registering new applications for AppOnly access (using _layouts/15/appregnew.aspx) so I need to switch to Certificate authentication for my new project.
I created App in AZURE AD, granted required permissions, created certificate. I can see in AZURE AD that there are successful authentication entries in authentication log for this application, but when I try to connect from my php I get error 500 and in my PHP error log I get following errors:

[02-Jan-2026 14:20:51 UTC] PHP Fatal error: Uncaught Office365\Runtime\Http\RequestException: {"error_description":"ID3035: The request was not valid or is malformed."} in c:\MY_APP_PATH\vendor\vgrem\php-spo\src\Runtime\ClientRequest.php:137 Stack trace: #0 c:\MY_APP_PATH\vendor\vgrem\php-spo\src\Runtime\ClientRequest.php(102): Office365\Runtime\ClientRequest->validate(Object(Office365\Runtime\Http\Response)) #1 c:\MY_APP_PATH\vendor\vgrem\php-spo\src\Runtime\OData\ODataRequest.php(128): Office365\Runtime\ClientRequest->executeQueryDirect(Object(Office365\Runtime\Http\RequestOptions)) #2 c:\MY_APP_PATH\vendor\vgrem\php-spo\src\Runtime\ClientRequest.php(83): Office365\Runtime\OData\ODataRequest->executeQueryDirect(Object(Office365\Runtime\Http\RequestOptions)) #3 c:\MY_APP_PATH\vendor\vgrem\php-spo\src\Runtime\ClientRuntimeContext.php(81): Office365\Runtime\ClientRequest->executeQuery(Object(Office365\Runtime\Actions\ReadEntityQuery)) #4 c:\MY_APP_PATH\ in c:\MY_APP_PATH\vendor\vgrem\php-spo\src\Runtime\ClientRequest.php on line 137
Error throws on line
$whoami = $ctx->getWeb()->getCurrentUser()->get()->executeQuery();
and any other using context. Do I miss something in my PHP code or do I have to set something more on sharepoint/AAD side?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authModern auth flows: OAuth, certificate, TOTP, app registrationlegacy-authUsername/password, basic auth, deprecated auth methods

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions