2

I am trying to connect my mobile app to on premise SharePoint 2013 server. I have followed some of the blogs on authenticating using JavaScript but all of them are explaining to connect SharePoint online (Office 365).

I have tried one of the approach and I was getting below Error.

<psf:error>
<psf:value>0x80048820</psf:value>
<psf:internalerror>
<psf:code>0x80045c01</psf:code>
<psf:text>Invalid STS request.&#x000D;&#x000A;</psf:text>
</psf:internalerror>
</psf:error>

Envelope which I used is as below:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Actions:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://login.microsoftonline.com/extSTS.srf</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken>
<o:Username>' + emailAddress + '</o:Username>
<o:Password>' + password + '</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<a:EndpointReference>
<a:Address>' + siteFullUrl + '</a:Address>
</a:EndpointReference>
</wsp:AppliesTo>
<t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>

$.ajax({
    url: "http://login.microsoftonline.com/extSTS.srf",
    data: env,
    crossDomain: true,
    contentType: "application/soap+xml; charset=utf-8",
    type: 'POST',
    dataType: 'xml',
    success: function (msg, textStatus, result) {
        var currentDate = new Date();
        var responseBody = $(result.responseText).find("S\\:Body");
        var requestSecurityTokenResponse = responseBody.find("wst\\:requestSecurityTokenResponse");
        var lifeTime = requestSecurityTokenResponse.find("wst\\:LifeTime");
        var expiresAt = lifeTime.find("wsu\\:Expires").text();

        token = $(result.responseText).find("wsse\\:BinarySecurityToken").text();

        alert(result.responseText);

        getFedAuthCookies();
    },
    error: function (jqXHR, textStatus, errorThrown) {
        alert(errorThrown + 'error login:' + jqXHR.responseText);
    },
    complete: function (jqXHR, textStatus) {

    }
});

Is there any SRF (https://login.microsoftonline.com/extSTS.srf) link for SharePoint 2013 on premise.

How can I authenticate users using JavaScript?

Thank you in advance.

6
  • 1
    Hi Rahul, did you find the solution? we also have a same issue.
    – P S
    Apr 14, 2016 at 13:08
  • @PS No I didn't found anything yet. Apr 14, 2016 at 16:12
  • Hi did you found any solution on these
    – Subha
    Jul 13, 2017 at 14:30
  • @Subha Hi Subha, No I am still not able to find any solution on this. Jul 13, 2017 at 18:19
  • This doesn't and will not work for on premise sharepoints
    – michalh
    Aug 10, 2018 at 10:39

1 Answer 1

1

If your password has special characters it can interfere with XML syntax, please try only alphanumeric password or escape your password.

Your Answer

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

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