Linbik Integration
Connect your application to Linbik's authentication gateway in minutes
Register Community
Create your community and get Client ID + RSA public key
Redirect Users
Send users to /auth/{clientId} for authentication
Verify JWT
Receive JWT token and verify with RSA public key
Authentication Flow
User Clicks "Login with Linbik"
Your application redirects user to Linbik with your Client ID
https://linbik.com/auth/YOUR_CLIENT_ID
User Authenticates on Linbik
User logs in (or uses existing session) and selects profile
John Doe
@johndoe
JWT Token Issued
Linbik signs a JWT with your community's private RSA key
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMjMiLCJ1c2VyTmFtZSI6ImpvaG5kb2UiLCJuaWNrTmFtZSI6IkpvaG4gRG9lIiwiY29kZSI6InRlc3QiLCJleHAiOjE3MzAwMDAwMDB9.signature
User Redirected to Your App
Token sent to your registered callback URL
https://yourapp.com/callback?token=JWT_HERE
You Verify & Create Session
Verify JWT signature with public key and extract user info
✓ JWT Valid - User Authenticated
userId: 123, userName: johndoe, nickName: John Doe
JWT Token Claims
| Claim | Type | Description | Example |
|---|---|---|---|
| userId | string | Unique user identifier (GUID) | "a1b2c3d4-..." |
| userName | string | Unique username (profile handle) | "johndoe" |
| nickName | string | Display name | "John Doe" |
| code | string | Custom code parameter (optional) | "test" |
| exp | number | Expiration timestamp (3 minutes) | 1730000000 |
Code Examples
Node.js + Express
const express = require('express');
const jwt = require('jsonwebtoken');
const fs = require('fs');
const app = express();
const publicKey = fs.readFileSync('linbik_public_key.pem', 'utf8');
// Callback endpoint
app.get('/callback', (req, res) => {
const token = req.query.token;
try {
const decoded = jwt.verify(token, publicKey, {
algorithms: ['RS256']
});
// User authenticated!
const userId = decoded.userId;
const userName = decoded.userName;
const nickName = decoded.nickName;
// Create your own session
req.session.userId = userId;
res.redirect('/dashboard');
} catch (error) {
res.status(401).send('Invalid token');
}
});
app.listen(3000);
Python + Flask
from flask import Flask, request, redirect, session
import jwt
app = Flask(__name__)
app.secret_key = 'your-secret-key'
# Load public key
with open('linbik_public_key.pem', 'r') as f:
public_key = f.read()
@app.route('/callback')
def callback():
token = request.args.get('token')
try:
# Verify JWT
decoded = jwt.decode(
token,
public_key,
algorithms=['RS256']
)
# Store in session
session['user_id'] = decoded['userId']
session['user_name'] = decoded['userName']
session['nick_name'] = decoded['nickName']
return redirect('/dashboard')
except jwt.InvalidTokenError:
return 'Invalid token', 401
if __name__ == '__main__':
app.run(port=3000)
PHP
<?php
require_once 'vendor/autoload.php';
use \Firebase\JWT\JWT;
use \Firebase\JWT\Key;
// Load public key
$publicKey = file_get_contents('linbik_public_key.pem');
$token = $_GET['token'];
try {
// Verify JWT
$decoded = JWT::decode(
$token,
new Key($publicKey, 'RS256')
);
// Start session
session_start();
$_SESSION['user_id'] = $decoded->userId;
$_SESSION['user_name'] = $decoded->userName;
$_SESSION['nick_name'] = $decoded->nickName;
header('Location: /dashboard');
} catch (Exception $e) {
http_response_code(401);
echo 'Invalid token';
}
?>
C# / ASP.NET Core
using Microsoft.AspNetCore.Mvc;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.IdentityModel.Tokens;
using System.Security.Cryptography;
public class CallbackController : Controller
{
[HttpGet("/callback")]
public IActionResult Callback(string token)
{
var publicKey = File.ReadAllText("linbik_public_key.pem");
var rsa = RSA.Create();
rsa.ImportFromPem(publicKey);
var validationParameters = new TokenValidationParameters
{
IssuerSigningKey = new RsaSecurityKey(rsa),
ValidateIssuer = false,
ValidateAudience = false
};
try
{
var handler = new JwtSecurityTokenHandler();
var principal = handler.ValidateToken(
token, validationParameters, out var validatedToken
);
var userId = principal.FindFirst("userId")?.Value;
var userName = principal.FindFirst("userName")?.Value;
// Create your session...
return Redirect("/dashboard");
}
catch
{
return Unauthorized("Invalid token");
}
}
}
HTML + Vanilla JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Linbik Login</title>
</head>
<body>
<button onclick="loginWithLinbik()">
Login with Linbik
</button>
<script>
const CLIENT_ID = 'YOUR_CLIENT_ID_HERE';
function loginWithLinbik() {
// Redirect to Linbik
window.location.href =
`https://linbik.com/auth/${CLIENT_ID}`;
}
// Handle callback (on your callback page)
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('token');
if (token) {
// Send to your backend for verification
fetch('/api/verify-token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token })
})
.then(res => res.json())
.then(data => {
console.log('User authenticated:', data);
window.location.href = '/dashboard';
});
}
</script>
</body>
</html>
Need Help?
Our developer support team is here to help you integrate Linbik into your application