Exchange Sign In Code
const url = 'https://example.com/auth/oauth/exchange/';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"code":"example","nonce":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/auth/oauth/exchange/ \ --header 'Content-Type: application/json' \ --data '{ "code": "example", "nonce": "example" }'Exchange a single sign-on code for a browser session.
When the SPA shares the API’s origin, an OAuth or SAML callback redirects
with a one-time code in the URL fragment instead of setting the refresh
cookie. The sign-in page posts that code here, and the response sets the
httpOnly refresh cookie and its CSRF cookie the way /auth/login does
in cookie mode, with a null refresh_token in the body.
A code is valid once, for two minutes, only from the browser the callback redirected, and only with the nonce the page started the sign-in with. Every refusal is the same 401.
Parameters
Section titled “ Parameters ”Header Parameters
Section titled “ Header Parameters ”Request Body required
Section titled “ Request Body required ”object
The one-time code from the code parameter of the sign-in redirect’s URL fragment.
The nonce the page sent when it started this sign-in.
Example generated
{ "code": "example", "nonce": "example"}Responses
Section titled “ Responses ”Successful Response
object
Example
{ "token_type": "bearer"}Bad request — invalid query parameters or payload
Unauthorized — missing or invalid credentials
Forbidden — caller lacks access to this resource
Not found
Validation error
Too many requests — retry after the advertised interval
Headers
Section titled “ Headers ”Seconds until the request may be retried
Internal server error
Service unavailable — the database could not serve the request