I am trying to play Scorm contents via Sakai LMS from my application. For doing that, I want to get the user session after logging in to Sakai and pass it for any other calls. I am able to get the user session cookie after login from Sakai via a rest call, but I am not able to pass the "Set-cookie" in the header or Store the cookie manually so that I will be able to use them to call other URL's that plays the Scorm or invokes other functionalities for the current user. How can I use the cookie returned by the getSession API to do other functionalities for the logged in user?
I have tried passing the response header from the login to make the next API call.
I have tried forming the Session and adding it to the header after removing the 'HTML only' like "SAKAI2SESSIONID="+session+".domain; Path=/;"
I have tried passing the session id and cookie in the response and manually storing it in the local storage
-----1------
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = client.execute(httpPost);
Header[] headers = response.getAllHeaders();
String session=EntityUtils.toString(response.getEntity());
response.setHeader("Set-Cookie","SAKAI2SESSIONID="+session);
----3----
function getSessionId() {
let data = {
password: "pass",
userId: "user"
}
fetch('http:ldomain/sakai/getSession', {
method: 'POST',
body: JSON.stringify(data),
headers:{
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*"
},
})
.then(response => response.json())
.then(response => {
localStorage.setItem('SAKAI2SESSIONID', response.entity.cookie[0])
document.cookie= response.entity.cookie[0];
})
.catch(error => console.error('Error:', error))
}
even though I tried all these when I try to hit Scorm URL after doing this, it redirects me to the login page again.