Search code examples
restsharepointforms-authenticationwebrequest

Invalid STS Request when Trying to Authenticate for SharePoint Access with REST API


I'm trying to follow the instructions at the below link, but it's failing right at step 1. The response from https://login.microsoftonline.com/extSTS.srf is "Invalid Request". I'm copying the XML directly into Postman, updating username/password, and posting to that url, but it does not like it. Are there other things I need to set up? And to confirm, it wouldn't give this kind of error if I simply botched the username/password, right?

https://allthatjs.com/2012/03/28/remote-authentication-in-sharepoint-online/

Error Response:

<?xml version="1.0" encoding="utf-8"?>
<S:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:S="http://www.w3.org/2003/05/soap-envelope">
    <S:Header>
        <psf:pp xmlns:psf="http://schemas.microsoft.com/Passport/SoapServices/SOAPFault">
            <psf:serverVersion>1</psf:serverVersion>
            <psf:authstate>0x80048800</psf:authstate>
            <psf:reqstatus>0x80045c01</psf:reqstatus>
            <psf:serverInfo ServerTime="2020-05-27T18:00:52.0727053Z">PROD-CHI-012.ProdSlices rid:83065b9d-8e7e-40a7-a3df-842141279c00</psf:serverInfo>
        </psf:pp>
    </S:Header>
    <S:Body xmlns:S="http://www.w3.org/2003/05/soap-envelope">
        <S:Fault>
            <S:Code>
                <S:Value>S:Sender</S:Value>
                <S:Subcode>
                    <S:Value>wst:InvalidRequest</S:Value>
                </S:Subcode>
            </S:Code>
            <S:Reason>
                <S:Text xml:lang="en-US">Invalid Request</S:Text>
            </S:Reason>
            <S:Detail>
                <psf:error xmlns:psf="http://schemas.microsoft.com/Passport/SoapServices/SOAPFault">
                    <psf:value>0x80045C01</psf:value>
                    <psf:internalerror>
                        <psf:code>0x80045C01</psf:code>
                        <psf:text>AADSTS90023: Invalid STS request.</psf:text>
                    </psf:internalerror>
                </psf:error>
            </S:Detail>
        </S:Fault>
    </S:Body>
</S:Envelope>

Solution

  • You could follow this demo

    My test demo for your reference.

    enter image description here

    enter image description here