In-app authentication offers you password-less access to the mini-courses in the application in which mini-courses are embedded. You can easily present training modules, exclusive tutorials and mini-courses to paid members and subscribers within your existing application. Integrate Mini Course Generator with your web-app or mobile-app in minutes, creating a seamlessly accessible in-product academy that enriches the engagement with your audience.
Granting access to your learners through in-app authentication differs from embedding mini-courses in that when your mini-courses are integrated in your application, your content can only be reached by exclusive users of your web or mobile application.
If the situation below matches to your use-case:
- you have your own application (not a 3rd party app),
- you have access to back-end codes of your application and are able to make changes,
- you are looking to use mini-courses in your own application while tracking users data without any additional login,
- you want your learners to access your mini-courses through in-app authentication,
then contact us through the live chat widget to get a quote.
Technical Requirements for In-App Authentication #
👀This feature requires some back-end coding ability.
When building applications that need to securely pass user data, encryption becomes a vital part of the process. Here’s an example of how to encrypt user data and generate a magic link for in-app authentication.
Code Overview #
var CryptoJS = require("crypto-js");
var collectionId = "YOUR_COLLECTION_ID";
var secretKey = CryptoJS.enc.Utf8.parse("YOUR_SECRET_KEY");
var courseCode = "YOUR_COURSE_CODE"; // Optional
var host = "YOUR_CUSTOM_DOMAIN"; // Optional
function encryptData(data) {
let encryptedBytes = CryptoJS.AES.encrypt(
CryptoJS.enc.Utf8.parse(JSON.stringify(data)),
secretKey,
{ mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 },
);
return encodeURIComponent(encryptedBytes.toString());
}
let data = {
//courseCollectionId: collectionId, // Optional
//courseCode: courseCode, // Optional
//externalIds: ["Your external Id 1", "Your external Id 2"], // Optional (Array)
//host: host, // Optional
//name: "You can set name surname", // Optional
//email: "You can set email", // Optional
username: "You have to set username",
};
var token = encryptData(data);
console.log("<https://gateway.minicoursegenerator.com/api/learner-auth/{YOUR_SHOP_ID}/generate-magic-link?token=${token}>");
Key Components #
- CryptoJS Library: Used to securely encrypt user data.
- Secret Key: This key is used to encrypt the data. Make sure this is stored securely. You can find your secret key in-app authentication part of learner access sample code inside.
- Data: Includes essential fields like username and other optional fields such as courseCode, courseCollectionId and host(for custom domain).
If only the username is provided in data object, the user will be redirected to their profile page. If both the username and courseCollectionId are included, the user will be directed to the collection page. When the username, courseCollectionId, and courseCode are all sent together, the user will be taken directly to the course page.
Additionally, if you have defined an External ID for your collections, you can assign the user directly to those collections and direct the user to the profile page by sending externalIds as an array in the data.
- Token Generation: The encryptData function takes the user data, encrypts it, and returns a token that can be appended to an API URL for generating magic links.
Usage Example #
Once you generate the token, you can use this API URL in your application for user authentication:
"<https://gateway.minicoursegenerator.com/api/learner-auth/{YOUR_SHOP_ID}/generate-magic-link?token=${token}>"
This URL can be redirected (or embedded in an iframe) to authenticate users securely.
This simple approach ensures that user-specific information is protected when sent across the network for authentication or other purposes.