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.
</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.