The usual way to sign users in to a mobile app is to open a browser with the hosted login page, then come back to the app with an authorization code. It is safe and it supports every kind of login, but the user leaves your app's screens to do it.
For your own apps, AuthAction now offers another way. With in-app sign-in, your app shows its own login screens and sends what the user types to AuthAction. You get an authorization code and exchange it at the token endpoint as usual. No browser opens.
It follows the IETF draft
OAuth 2.0 for First-Party Applications
through a new endpoint, /oauth2/authorize-challenge.
In-app sign-in is in beta, and details may change. Your app handles the user's password or code, so turn it on only for an app you own.
What happens on your screens
| Sign-in | Where it happens |
|---|---|
| Email and password | Your screens |
| Emailed code | Your screens |
| Verifying an email address after password | Your screens |
| Choosing an organization | Your screens |
| Social, SAML and other identity providers | The browser (redirect_to_web, or a web button) |
| Sign-up, password reset and passkeys | The browser |
Two-step verification works too: a user with an authenticator app types its code on your screens.
Start with an email address
The first request names the user. A native app also sends a PKCE
code_challenge:
curl https://your-tenant.eu.authaction.com/oauth2/authorize-challenge \
-d client_id=YOUR_CLIENT_ID \
-d response_type=code \
-d username=alice@example.com \
-d code_challenge=YOUR_CODE_CHALLENGE \
-d code_challenge_method=S256
When more is needed, the answer is 403 with an auth_session, and it says
what is missing:
{
"error": "insufficient_authorization",
"auth_session": "q0nX...",
"method_required": true,
"methods": ["password", "email_code"]
}
Send the auth_session on every following request. If you already have the password, send username and
password on the first request to finish in one step.
The first request also takes scope, audience (or resource), nonce,
organization and ui_locales. There is no redirect_uri.
Answer what it asks for
Each answer tells your app which screen to show next:
| In the answer | Send |
|---|---|
username_required |
username (an email address) |
method_required |
password, or method=email_code |
password_required |
password |
otp_required |
otp. Send method=email_code for a new code. |
organization_required |
organization: an id or name from organizations |
mfa_required |
otp with the code from the user's authenticator app, or recovery_code |
For example, to sign in with an emailed code:
curl https://your-tenant.eu.authaction.com/oauth2/authorize-challenge \
-d auth_session=q0nX... \
-d method=email_code
curl https://your-tenant.eu.authaction.com/oauth2/authorize-challenge \
-d auth_session=q0nX... \
-d otp=123456
Get tokens
A finished sign-in answers 200 with an authorization code:
{ "authorization_code": "Xk3v..." }
Exchange it at the token endpoint, without a redirect_uri:
curl https://your-tenant.eu.authaction.com/oauth2/token \
-d grant_type=authorization_code \
-d client_id=YOUR_CLIENT_ID \
-d code=Xk3v... \
-d code_verifier=YOUR_CODE_VERIFIER
A backend sends client_secret in place of code_verifier.
Always handle redirect_to_web
Some sign-ins can't happen on your screens. When that is the case, the answer is
403 with error: "redirect_to_web", and your app opens the hosted login page
with a normal authorize request. When an email address belongs to an
organization with its own identity provider, the answer also names the
connection and organization. Pass both to /oauth2/authorize.
Too many wrong passwords or codes also lead to the browser, so handle
redirect_to_web at every step.
Trying it with AuthAction
In-app sign-in is free and unlimited on AuthAction's free plan. Open the
application in the dashboard and turn on Authentication policy > In-app
sign-in, or set firstPartyLogin to true on
PATCH /api/v1/applications/{id}.
It works for two application types:
- Native (
native) apps send a PKCEcode_challengeon the first request. Create this type with the Management API. - Single-page (
spa) apps send theirclient_secreton every request, so call the endpoint from your backend and never put the secret in the browser.
The in-app sign-in docs list every parameter and error.