The system has to call a web service on the Mission Center with the learnerId to obtain an Authentication Token, which is a random and unique string (see documentation):
POST /api/learner-authorization/v1/learners/authToken
{
"UserIdentifier": "46e11440-ea40-11e7-a88a-3d64957b0864"
}
The response should be either a 404 code if the learnerId has not been found, a 401 code if unauthorized or something like that:
{
"authToken": "67ad8ef9452d5e7cda467238de7865facd765"
}
Which is the authentication token to be used in the next step.
Log the learner in the application
In order to log the learner in the application, the authentication token must be passed to the application by using a special function. Include this piece of code in your page:
function postAuthToken(authToken, isCreation = null) {
post(`com.teachonmars://globals.login?authToken=${authToken}&profileCreation=${isCreation}`);
}
function post(url) {
if (window.top == window) {
window.location.href = url;
} else {
window.top.postMessage(url, "*");
}
}
What you need to do now is call the postAuthToken function with the token, and the application will automatically log the learner in. For example:
<script type="javascript">
var token = "67ad8ef9452d5e7cda467238de7865facd765";
postAuthToken(token, true);
</script>
Comments
0 comments
Please sign in to leave a comment.