title OAuth 2 flow with 2-Factor Authentication participant User participant MIS participant Auth participant IL User->MIS: Request login MIS->Auth: <> Auth->Auth: Check whether MSP is not blocked alt MSP is active Auth-->User: <> else MSP is blocked Auth-->User: <> end User->+Auth: Username/Password alt Authentication {Username/Password} successful Auth->Auth: Authenticate user {Username/Password} alt 2FA enable Auth-->MIS: <> Auth-->User: <> Auth-->-User: <> User->Auth: OTP Auth->Auth: Authenticate user {OTP} alt Authentication successful Auth->Auth: Change {2fa_access_token} on {access_token} Auth-->MIS: <> else OTP Invalid opt Auth->Auth: Block user end opt Auth-->User: <> end else 2FA reset Auth-->User: <> User->+Auth: Factor Auth-->User: <> Auth-->-User: <> User->Auth: OTP Auth->Auth: Authenticate user {OTP} alt Authentication successful Auth->Auth: Change {2fa_access_token} on {access_token} Auth-->MIS: <> else OTP Invalid opt Auth->Auth: Block user end opt Auth-->User: <> end else 2FA disable Auth-->MIS: <> end else Password invalid Auth-->User: <> opt Auth->Auth: Block user end opt end alt Authentication successful Auth-->MIS: <> MIS->Auth: <> Auth-->MIS: <> MIS->IL: <> IL-->MIS: <> opt Select context MIS->User: Show contexts User->MIS: Context end opt MIS->Auth: <> Auth->Auth: Authenticate and refresh token Auth-->MIS: <> opt Change factor proccess User->Auth: Request for change factor end opt else Authentication failed Auth-->MIS: <>