Choose a tenant name.
The tenant name cannot be changed later. It should be a short lowercase identifier for your company or app without spaces or special characters. Only letters are allowed.
Here are some examples for your inspiration: microsoft, reddit, amazon, netflix, quora
The API Key appears here when you have chosen a tenant name.
Select below whether to use our SDK for Javascript or to make your own custom implementation.
Add this script to your page:
<script src="https://cdn.jsdelivr.net/gh/Login-Broker/javascript@main/loginbroker.v1.js" />
USE IT LIKE THIS:
// Create a callback function to handle when a session is received
function handleSessionReceived(sessionId) {
console.log('Received sessionId:', sessionId);
// Verify the sessionId on your server-side or API and get the logged-in user email
}
// Create a callback function to handle errors
function handleErrorReceived(error) {
console.log(‘Error happened:’, error);
}
// Create a new instance of the useLoginBroker function
const loginBroker = useLoginBroker(‘tenantName‘, ‘platform‘, handleSessionReceived, handleErrorReceived);
// Start the login process
loginBroker.startLoginProcess();
Where tenantName is the name you have chosen above.
And platform is google, facebook, microsoft, apple, linkedin or github.
If you cannot include a script or want to implement in another type of application, then you can follow this guide to implement it manually:
Verify by following the step below
After the user is logged in, you receive a “sessionId” which you need to use to verify that the user is indeed logged. This verification must happen from your server-side code.
The result of the login is a “sessionId” which you need to send to your own api or handle in your server-side code. You cannot let the client verify itself.
From your server-side code, call the following endpoint:
GET https://api.login.broker/tenant-name/auth/result/sessionId
(If your server-side code insists on adding a “scheme” to your Authorization header, you can use the scheme: “Secret”)
The response is the following json document:
{ "email": "The fully verified email id of the user", "tenantName": "your own tenant name", "platform": "google", "status": "pending or failed or completed", "error": "" }
With the email and the “completed” status, you can be certain that the user is properly authenticated and you can consider them logged in to your own system.
It is recommended, if the user is not yet signed up, to sign them up automatically upon their first login.
Need help? Contact nb@gyxi.com for questions or comments.