'use client' import type { FC } from 'react' import { Avatar } from '@langgenius/dify-ui/avatar' import { Button } from '@langgenius/dify-ui/button' import { useState } from 'react' import { deviceApproveAccount, deviceDenyAccount } from '@/service/device-flow' import { approveErrorCopy } from '../utils/error-copy' type Props = { userCode: string accountEmail?: string accountName?: string accountAvatarUrl?: string | null 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, accountName, accountAvatarUrl, 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

difyctl is requesting access. If you didn't start this from your terminal, click Cancel.

{accountName && (

{accountName}

)} {accountEmail && (

{accountEmail}

)}
{defaultWorkspace && (
Workspace: {' '} {defaultWorkspace}
)}
) } export default AuthorizeAccount