Send users a sign-in link
Give users a link that signs them in to your application, connects a provider account or carries a campaign, and handle a callback that does not match.
To bring someone into your application from an email, a chat message or a QR code, send them a
link to a page on your application that starts sign-in, for example
https://yourapp.com/login. Each click on that link starts a new sign-in, so it works for anyone,
as often as they open it.
Link to your own start route
Your start route is the page that begins the authorization request. When someone opens it, it:
- creates a new
stateand PKCE code verifier for this visit, - keeps both for this browser, in an HttpOnly cookie or your server session,
- redirects to
/o/authorize/with thatstateand the code challenge.
Your callback then checks the state it receives against the one stored for this browser, and
exchanges the code with the stored verifier.
| Your application | Its start route |
|---|---|
| A server-rendered web app | The login route in the Next.js, Python or Django guide |
| A single-page app | The code that keeps the verifier in sessionStorage before redirecting, in the React guide |
| A mobile or desktop app | The code that opens the system browser, in Mobile and desktop |
| An app using an OpenID Connect library | The library's sign-in call. See Any OpenID Connect library |
Do not share a onefold address
onefold's sign-in and consent pages carry your request in their address, with its state and
code challenge. Those belong to the browser that started the sign-in. Someone who opens a copied
address can sign in and approve, but your callback finds no matching state and refuses the
result. This applies to an address copied from the browser and to the link the URL Builder shows.
Turning off Require PKCE does not make an authorization URL safe to share. A state sent to
everyone no longer protects your callback from a forged sign-in, and a link already sent keeps the
scopes and redirect URI it was made with after you change them.
Links for common tasks
Each link is a start route. They differ in what the route adds to the request.
| Link | What the start route adds |
|---|---|
| Sign in | scope=openid identity |
| Connect a provider account | The provider's scope, for example socials:discord. The provider must be turned on for the application. See Social login |
| A campaign | The utm_* parameters from its own address, copied onto the authorization URL. See Campaign attribution |
A campaign link that also connects Discord:
https://yourapp.com/connect/discord?utm_source=newsletter&utm_campaign=springIts start route redirects to:
https://onefold.eitozx.com/o/authorize/?response_type=code&client_id=…&redirect_uri=…
&scope=openid+identity+socials:discord&state=…&code_challenge=…&code_challenge_method=S256
&utm_source=newsletter&utm_campaign=springCampaigns are recorded on onefold's pages, not on yours, so a start route that drops the utm_*
parameters loses the campaign.
Handle a callback that does not match
When your callback receives a state that does not match the one stored for this browser, or
there is none stored, the result is not yours to use:
- Discard the
code. Do not exchange it. - Remove
codeandstatefrom the address, and sendReferrer-Policy: no-referrerfrom the callback, so the code does not reach another site. - Show a page with a Sign in again link to your start route.
Compare the state with the value stored for this browser. Looking a state up by its value
alone would accept a copied sign-in.
Do not redirect to the start route automatically. A missing state most often means a lost cookie,
for example a different browser or blocked storage, and an automatic retry repeats the same
failure without the person seeing why.
When the code exchange answers invalid_grant, start a new sign-in from your start route. Do not
present the code again: a code works once and expires 60 seconds after it is issued. See
Token exchange.
Try it from the portal
The URL Builder on the application's OAuth2 tab runs a test sign-in and shows the result. Its link works once, for you, so it is not a link to send to users.
Any OpenID Connect library
Configure a standard OpenID Connect client library to sign users in with onefold, with the settings to use and the options to turn off.
Protect your API
Verify who is calling your own API using onefold — with userinfo, or with audience-bound JWT access tokens issued for a protected resource you register (RFC 8707).