Add sign-in and data to your site
Add a “Sign in with ItIsNow” button to any website. Users click it, a small window opens, they log in or create an account, and your site gets their details. Accounts are shared, so someone who signed up on one site can sign in to any other with the same login. Your app also gets its own database to store data.
Building with an AI assistant? Give it https://api.itisnow.net/skill.md and it will know how to add sign-in correctly.
Quick start
Create an app
Open the dashboard, log in, and create an app. Add the address of your website, for example https://mysite.com (include http or https, and the port if there is one). Only addresses you list can use your app. For testing add http://localhost:3000 too.
Paste the snippet
Put this where you want the button to appear. Your app id is on your app's page.
<script src="https://api.itisnow.net/button.js" data-app-id="YOUR_APP_ID"></script>
That is the whole install. A button appears. When someone signs in it turns into “Signed in as name” with a sign out link, and it remembers them next time they visit.
Do something when they sign in
<script src="https://api.itisnow.net/button.js"
data-app-id="YOUR_APP_ID"
data-onlogin="onLogin"></script>
<script>
function onLogin(user, token) {
// user = { id, username, email, email_verified }
console.log('Hello', user.username);
}
</script>Button options
| Attribute | What it does |
|---|---|
data-app-id | Required. Your app id. |
data-onlogin | Name of your function to call after sign in, with (user, token). |
data-onlogout | Name of your function to call after sign out. |
data-theme | dark (default) or light. |
data-text | Button text. Default “Sign in with ItIsNow”. |
data-target | CSS selector of an element to put the button in, like #login-slot. |
data-button | Set to false to hide the built-in button and use your own (call ItIsNow.signIn()). |
Also available: ItIsNow.signOut(), ItIsNow.getUser(), ItIsNow.getToken(), ItIsNow.onLogin(fn), ItIsNow.onLogout(fn), and a itisnow:login browser event.
Check the user on your server
Anyone can edit what their own browser shows, so if signing in unlocks anything real (data, an account, purchases), send the token to your server and check it there. No secret needed:
const r = await fetch('https://api.itisnow.net/api/me', {
headers: { Authorization: 'Bearer ' + token }
});
const data = await r.json();
if (!r.ok || data.app_id !== 'YOUR_APP_ID') throw new Error('Not signed in');
// data.user.id is now safe to trust. Use it as the account key in your database.Always check app_id, so a token from a different site cannot be used on yours. The user id is the same on every site.
Store data
Every app has its own database, a bit like Firebase. Data lives in collections of JSON documents. Each app only ever sees its own data. Storage is shared across all the apps in your account: the free plan includes 3 GB and up to 5 apps, and bigger plans are coming soon. After a user signs in, save and read from the browser:
const notes = ItIsNow.collection('notes');
const doc = await notes.add({ text: 'Buy milk', done: false }); // creates a document
const mine = await notes.list(); // { docs: [...], total, limit, offset }
await notes.update(doc.id, { done: true }); // changes only the fields you send
await notes.set('my-id', { text: 'Hi' }); // create or replace with your own id
const one = await notes.get(doc.id); // { id, owner, data, created_at, updated_at }
await notes.remove(doc.id);list options: { limit: 20, offset: 0, order: 'updated_at', dir: 'desc', where: { done: false }, owner: 'me' }. Each document can be up to 256 KB. For one record per user (settings, a profile), use their user id as the document id, like ItIsNow.collection('settings').set(user.id, {...}).
Who can read and write
Set this per collection on your app's Manage data page, or with the API. New collections are private.
| Mode | What it means |
|---|---|
private (default) | Each signed-in user can only see and change their own documents. |
shared | Any signed-in user can read all documents, and change only their own. |
public | Anyone can read, even signed out. Signed-in users change only their own. |
server | Only your server, using your app secret. |
From your server (full access)
Your app secret gives your server access to every document in your app, whatever the mode. Keep it on your server.
curl -X POST https://api.itisnow.net/api/data/orders \
-H "X-App-Id: APP_ID" -H "X-App-Secret: APP_SECRET" \
-H "Content-Type: application/json" \
-d '{"item": "Book", "paid": true}'
curl "https://api.itisnow.net/api/data/orders?where[paid]=true&limit=20" \
-H "X-App-Id: APP_ID" -H "X-App-Secret: APP_SECRET"Add ?owner=USER_ID when creating a document from your server to make it belong to a user who has signed in to your app.
Data API
From a browser send Authorization: Bearer TOKEN (and X-App-Id for public reads). From your server send X-App-Id and X-App-Secret.
| Request | What it does |
|---|---|
GET /api/data/:collection | List documents. Query: limit (max 200), offset, order (created_at or updated_at), dir (asc or desc), where[field]=value, owner=me. |
POST /api/data/:collection | Create a document with a new id. Body is a JSON object. |
GET /api/data/:collection/:id | Read one document. |
PUT /api/data/:collection/:id | Create or replace a document. |
PATCH /api/data/:collection/:id | Change some fields. Send null to remove a field. |
DELETE /api/data/:collection/:id | Delete a document. |
GET /api/data | Server only. Lists your collections and storage used. |
GET /api/rules, PUT /api/rules/:collection, DELETE /api/rules/:collection | Server only. Read and set access modes. Body for PUT: {"mode": "shared"}. |
Collection names and ids use letters, numbers, - and _ (up to 64 and 128 characters). Errors come back as {"error": "code", "message": "..."}: auth_required and invalid_token (401), forbidden (403), not_found (404), id_taken (409), doc_too_large and storage_full (413), rate_limited (429).
See your users
Your app only ever sees the people who signed in to your app. Browse them on your app's page in the dashboard, or fetch them with your API key from your server:
curl https://api.itisnow.net/api/users \ -H "X-App-Id: APP_ID" -H "X-App-Secret: APP_SECRET"
Returns {"total": 2, "limit": 100, "offset": 0, "users": [{"id": 1, "username": "joe", "email": "[email protected]", "first_sign_in": "...", "last_sign_in": "...", "sign_ins": 3}]}. Use ?limit= (max 500) and ?offset= to page. The secret is shown once when you create the app, and you can make a new one any time. Keep it on your server, never in browser code.
Email verification
Users confirm their email before they can sign in anywhere. This is automatic.
- When someone creates an account in the sign-in window, we email them a link. After they confirm, they come back to your site and click the button once more.
- Accounts that are not confirmed within 12 hours are deleted automatically, so the person can simply sign up again.
- Email addresses with a
+in them (like[email protected]) are not accepted. - Because accounts are shared, an email only needs confirming once. Anyone who signs in to your site has a confirmed email, and
email_verifiedis alwaystruein the user you receive. - No email setup needed: emails come from
[email protected]with your app name as the sender name, for example “My Site <[email protected]>”. - Want your own address? Fill in your SMTP details under “Verification emails” when you create an app. We test the login when you save, and your password is stored encrypted.
Password resets are handled for you too, so you never build a “forgot password” page.
Account security
All of this is handled for you. Nothing changes in your code.
- Two-step login: people can turn on codes from an authenticator app (with backup codes). If they have it on, the sign-in window asks for the code after the password, then continues as normal.
- Passwords must be 8 to 128 characters and cannot be a common password or contain the username or email.
- Brute-force protection: too many wrong passwords or codes for one account locks sign-in to it for 15 minutes, from every address.
- People get an email whenever their password or two-step login changes, and can log out of every device and site from their account page.
Server redirect flow (advanced)
If you would rather do everything on your server without a popup, use the redirect flow. Add your exact callback URL (for example https://mysite.com/auth/callback) to your app.
- Send the user to
https://api.itisnow.net/login?app=APP_ID&redirect=CALLBACK_URL&state=RANDOMand saveRANDOMin their session. - They sign in on our page and come back to
CALLBACK_URL?code=...&state=RANDOM. Checkstatematches. - Swap the code for the user from your server (codes work once and expire in 5 minutes):
const r = await fetch('https://api.itisnow.net/api/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ app_id: APP_ID, app_secret: APP_SECRET, code: req.query.code })
});
const data = await r.json(); // { token, app_id, user: { id, username, email, email_verified } }Sign-in API reference
GET /api/me
Header Authorization: Bearer TOKEN. Returns {"app_id": "...", "user": {...}} or 401 invalid_token. Works from browsers and servers.
POST /api/revoke
Header Authorization: Bearer TOKEN. Invalidates the token (the button calls this on sign out).
POST /api/token
Body {"app_id", "app_secret", "code"} (redirect flow). Returns {"token", "app_id", "expires_in", "user"}. Errors: invalid_app (401), invalid_code (400).
GET /api/users
Headers X-App-Id and X-App-Secret. Lists the people who signed in to your app.
Security checklist
- The button needs no secret. Never put
app_secretin browser code, a mobile app, or a public repo. - Only the website addresses you add can use your app, so list exactly the sites you own.
- Verify the token on your server (above) before trusting a user, and keep sensitive collections
privateorserver. - Key your own data off
user.id, not email or username. - Use https in production.