Handle Redirects And Allowlists
Doc type: How-to guide
Goal and scope
Implement safe redirect handling for hosted auth, where:
redirectUrlis the hosted-auth return target.- Sign-in redirects are completed through OAuth and returned to a registered
redirect_uri.
Prerequisites and constraints
- Hosted-auth return URLs must be HTTPS (
https:only) and allowlisted. - OAuth
redirect_urivalues must exactly match one of the registered redirect URIs for yourclient_id. - OAuth Authorization Code + PKCE is required.
Steps
-
Enter hosted auth with a
redirectUrl.https://auth.yoyogroup.com/?redirectUrl=<encoded return URL> -
Validate the hosted
redirectUrltarget.- Require
httpsforredirectUrl. - Ensure the host/path is allowlisted for your app.
- Apply the same validation rules for logout redirects.
- Require
-
Use OAuth authorize redirects for hosted sign-in.
- Hosted auth continues the sign-in flow through OAuth.
- OAuth returns to your registered
redirect_uriwithcode(and optionalstate).
https://auth-int.yoyogroup.com/api/oauth/authorize?response_type=code&client_id=<appId>&redirect_uri=https%3A%2F%2Fyour-app.yoyogroup.com%2Fauth%2Fcallback&code_challenge=<code_challenge>&code_challenge_method=S256&state=<state> -
Validate and exchange on the callback.
- Verify
statebefore exchangingcode. - Exchange the code at
/api/oauth/tokenusing the exact sameredirect_uriused at authorize time. - Reject or fail safely when
redirect_uridoes not exactly match the registered URI.
- Verify
-
Build logout redirects through the public logout endpoint.
https://auth.yoyogroup.com/logout?redirectUrl=<encoded return URL>
Redirect state behavior
- Hosted auth stores
redirectUrlstate insessionStorageper tab, with a 15-minute TTL. - OAuth clients should store and validate
statein their own app session before token exchange.
Validation and troubleshooting
- If hosted-auth
redirectUrlis not allowed, the portal falls back to a safe destination. - If OAuth
redirect_uriis not registered exactly, authorization fails withinvalid_request. - If you see loops, verify allowlists and ensure you only redirect when the session is missing.