PHP, Python, .NET, Node.js

Follow this guide if your pages are rendered on the server, in PHP, Python, .NET or Node.js. At the end your users sign in with Block-Auth and your backend has a verified session for them.

What you'll build

Everything happens in your backend. You don't install anything from Block-Auth in the browser: your pages only need a normal link to sign in and a form to sign out.

Your backend sends the user to the Block-Auth login and receives them back on a callback with a one-time code. It redeems the code with your API secret, gets the user from Block-Auth and creates its own session.

  1. 1Your pages → Your backendGET /blockauth/login
  2. 2Your backend → Block-AuthPOST /api/auth/authorize
  3. 3Your backend → Your pagesRedirect to the login
  4. 4Your pages → Block-AuthThe user signs in
  5. 5Block-Auth → Your pagesBack with ?code&state
  6. 6Your pages → Your backendGET /blockauth/callback
  7. 7Your backend → Block-AuthPOST /api/auth/token
  8. 8Block-Auth → Your backend{ address, roles }
  9. 9Your backend → Your pagesSession cookie and redirect

Prepare your app

  1. In the Dashboard, create your application following the Integration Quickstart. As the domain, enter the host your users see (for example your-app.com).
  2. You set up the keys and the .env at the start of the first step, Install the client.