https://api.ub.bitbros.in
How the flow works
<your-site>/auth/callback with an access token in the URL fragment and a short-lived exchange code in the query string.
Dashboard setup (one time)
1
Set your site URL
Go to Project Settings in the urBackend dashboard and enter your frontend URL (e.g.,
https://myapp.com). urBackend uses this as the base for the post-login redirect.2
Open Social Auth settings
Go to Auth → Social Auth and select the provider you want to configure (GitHub or Google).
3
Copy the callback URL
urBackend displays a read-only callback URL for the selected provider:Copy this URL — you will register it with the provider in the next step.
4
Register the callback URL with the provider
Paste the callback URL into the provider’s developer console:
- GitHub: Settings → Developer settings → OAuth Apps → New OAuth App
- Google: Google Cloud Console → APIs & Services → Credentials → Create OAuth Client
5
Paste credentials and enable
Copy the Client ID and Client Secret from the provider console, paste them into the urBackend Social Auth form, and toggle the provider on.
Frontend implementation
1. Add login buttons
When a user clicks “Login with GitHub” or “Login with Google”, redirect their browser to urBackend’s start endpoint. Pass your publishable key as a query parameter (since this is a browser redirect, not afetch call).
2. Create the callback page
You must create a page at/auth/callback in your frontend. After the provider login completes, urBackend redirects the user here with tokens in the URL.
The callback page should:
- Check for an error in the query string
- Extract
tokenfrom the URL fragment andrtCodefrom the query string - Exchange
rtCodefor a refresh token by calling/api/userAuth/social/exchange - Store the tokens and redirect to your app
What urBackend sends to your callback URL
After a successful provider login, urBackend redirects to:The access token is placed in the URL fragment (
#) intentionally. Fragments are never sent to servers in HTTP requests, which prevents the token from leaking through referrer headers or server logs.Exchange endpoint
Endpoint:POST /api/userAuth/social/exchange
Headers:
Complete flow summary
Account linking
If a user signs in with a social provider and their provider account has a verified email that matches an existing urBackend user, the accounts are automatically linked. ThelinkedByEmail parameter in the callback URL will be true in this case.
New users created via social auth receive an internally generated hashed password to satisfy the users collection contract. They can set a real password later using the change-password endpoint.