'use client' import type { FC } from 'react' import { useState } from 'react' import { deviceApproveAccount, deviceDenyAccount } from '@/service/device-flow' import { approveErrorCopy } from '../utils/error-copy' type Props = { userCode: string accountEmail?: string defaultWorkspace?: string onApproved: () => void onDenied: () => void onError: (message: string) => void } /** * AuthorizeAccount is the account-branch authorize screen. Called with a * live console session already established (user bounced through /signin). * Posts to /openapi/v1/oauth/device/{approve,deny}; these endpoints mint * the dfoa_ token server-side. */ const AuthorizeAccount: FC = ({ userCode, accountEmail, defaultWorkspace, onApproved, onDenied, onError, }) => { const [busy, setBusy] = useState(false) const approve = async () => { setBusy(true) try { await deviceApproveAccount(userCode) onApproved() } catch (e) { onError(approveErrorCopy(e)) } finally { setBusy(false) } } const deny = async () => { setBusy(true) try { await deviceDenyAccount(userCode) onDenied() } catch (e) { onError(approveErrorCopy(e)) } finally { setBusy(false) } } return (

Authorize Dify CLI

Dify CLI (difyctl) is requesting access to your account. {' '}If you did not start this from your terminal, click Cancel.

{accountEmail && (

Signed in as {accountEmail}

)} {defaultWorkspace && (

Default workspace: {defaultWorkspace}

)}
) } export default AuthorizeAccount