- {/* It's not easy to override RootLayout without grouping everything into `(root)` dir */}
- {/* So I'm hacking a custom layout with full modal overlay */}
- {/* https://github.com/vercel/next.js/issues/50591 */}
- {}} // intentionally prevent closing
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Linking CLI with your account
-
-
-
-
-
-
-
-
-
- )
-}
-
-function AuthState({ user, apiKey, posthog, userIsLoading }) {
- const searchParams = useSearchParams()
- const searchParamsObj = searchParams ? Object.fromEntries(searchParams) : {}
- const { next, state } = searchParamsObj
-
- // TODO: Consider sending back onetime code to be used to get access token
- function redirectToCLI() {
- if (!next) return
- if (!(user?.email && apiKey)) return
-
- posthog?.capture('started CLI authorization', { email: user.email })
-
- const { email, accessToken, defaultTeamId } = user
- const newUrl = new URL(next)
- const searchParamsObj: UserConfig = {
- email,
- defaultTeamApiKey: apiKey,
- accessToken,
- defaultTeamId,
- }
- newUrl.search = new URLSearchParams(searchParamsObj).toString()
- window.location.href = newUrl.toString()
- }
-
- useEffect(
- function sendAuthorizationAnalytics() {
- if (state === 'success') {
- posthog?.capture('successfully authorized CLI')
- } else if (state === 'error') {
- posthog?.capture('failed to authorize CLI', {
- error: searchParamsObj.error,
- })
- }
- },
- [state, posthog, searchParamsObj.error]
- )
-
- let content
- if (state === 'error') {
- content = (
- <>
-
Error
-
Something went wrong, please try again
-
{searchParamsObj.error}
- {/* TODO: Nicer, but it should never happen */}
- >
- )
- } else if (state === 'success') {
- content = (
- <>
-
- {/* It's not easy to override RootLayout without grouping everything into `(root)` dir */}
- {/* So I'm hacking a custom layout with full modal overlay */}
- {/* https://github.com/vercel/next.js/issues/50591 */}
- {}} // intentionally prevent closing
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Linking CLI with your account
-
-
-
-
-
-
-
-
-
- )
-}
-
-function AuthState({ user, apiKey, posthog, userIsLoading }) {
- const searchParams = useSearchParams()
- const searchParamsObj = searchParams ? Object.fromEntries(searchParams) : {}
- const { next, state } = searchParamsObj
-
- // TODO: Consider sending back onetime code to be used to get access token
- function redirectToCLI() {
- if (!next) return
- if (!(user?.email && apiKey)) return
-
- posthog?.capture('started CLI authorization', { email: user.email })
-
- const { email, accessToken, defaultTeamId } = user
- const newUrl = new URL(next)
- const searchParamsObj: UserConfig = {
- email,
- defaultTeamApiKey: apiKey,
- accessToken,
- defaultTeamId,
- }
- newUrl.search = new URLSearchParams(searchParamsObj).toString()
- window.location.href = newUrl.toString()
- }
-
- useEffect(
- function sendAuthorizationAnalytics() {
- if (state === 'success') {
- posthog?.capture('successfully authorized CLI')
- } else if (state === 'error') {
- posthog?.capture('failed to authorize CLI', {
- error: searchParamsObj.error,
- })
- }
- },
- [state, posthog, searchParamsObj.error]
- )
-
- let content
- if (state === 'error') {
- content = (
- <>
-
Error
-
Something went wrong, please try again
-
{searchParamsObj.error}
- {/* TODO: Nicer, but it should never happen */}
- >
- )
- } else if (state === 'success') {
- content = (
- <>
-
-
- Use for running the sandboxes.
-
- }
- secret={apiKey}
- posthog={posthog}
- tip={
-
- Set as E2B_API_KEY environment variable to avoid passing it
- every time.
-
- }
- />
-
-
- Used only in the CLI, not needed in the SDK.
-
-
- Access token is for managing sandboxes with CLI - list/kill/connect, and for building custom sandbox templates with CLI.
-
-
- Acess token is not needed when logging in CLI via e2b auth login.
-
-