Use Cases

Authenticated Flows

On mobile devices, Descope supports running flows for initial and post authentication. With post authentication, or authenticated, flows, we support implementation of functionality like 'step up' and 'update user.' In this article, we explain how this is implemented.

Starting an Authenticated Flow

Starting an authenticated flow is similar to a unauthenticated or initial authentication flow, it simply requires the flow to be run's id and the refresh JWT of the currently authenticated user, in addition to the existing parameters.

import { useFlow } from '@descope/react-native-sdk'
 
const flow = useFlow()
const { session, manageSession } = useSession()
 
try {
  // When starting a flow for an authenticated user, provide the authentication info
  let flowAuthentication = undefined
  if (session) {
    const flowAuthentication = {
      /** The flow ID about to be run. */
      flowId: 'flow-id',
      /** The refresh JWT from an active descope session */
      refreshJwt: session.refreshJwt,
    }
  }
 
   // Some Android browsers (eg. Opera) 
   // don't support App Link redirects by default. 
   // We use the backup Custom Scheme in this case
  const backupCustomScheme = "";
  const resp = await flow.start('<URL_FOR_FLOW_IN_SETUP_#1>', '<URL_FOR_APP_LINK_IN_SETUP_#2>', backupCustomScheme, flowAuthentication)
  await manageSession(resp.data)
} catch (e) {
  // handle errors
}
Was this helpful?

On this page