From f00366af5e6460e0998b9e0bee98bf22d5ccf3c1 Mon Sep 17 00:00:00 2001 From: zhaoqing Date: Tue, 23 Jun 2026 17:18:44 +0800 Subject: [PATCH] fix: add EnvdAccessToken to runtime config for X-Access-Token auth --- e2b/config.go | 1 + e2b/sandbox.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/e2b/config.go b/e2b/config.go index d2447d0..6d7ca29 100644 --- a/e2b/config.go +++ b/e2b/config.go @@ -199,6 +199,7 @@ func (c *ConnectionConfig) toEnvdConfig(sandboxID string) *runtime.Config { RuntimePort: c.RuntimePort, APIKey: c.APIKey, RequestTimeout: c.RequestTimeout, + RuntimeToken: c.AccessToken, } // Pre-compute the full sandbox URL using the Protocol-aware logic so diff --git a/e2b/sandbox.go b/e2b/sandbox.go index e991ae4..f49a24f 100644 --- a/e2b/sandbox.go +++ b/e2b/sandbox.go @@ -104,7 +104,7 @@ func Create(ctx context.Context, template string, opts ...SandboxOption) (*Sandb return nil, fmt.Errorf("failed to create sandbox: %w", err) } - sb := newSandbox(config, api, resp.SandboxID, resp.TemplateID, resp.EnvdVersion) + sb := newSandbox(config, api, resp.SandboxID, resp.EnvdAccessToken, resp.TemplateID, resp.EnvdVersion) return sb, nil } @@ -125,7 +125,7 @@ func Connect(ctx context.Context, sandboxID string, opts ...SandboxOption) (*San return nil, fmt.Errorf("failed to connect to sandbox: %w", err) } - sb := newSandbox(config, api, resp.GetSandboxID(), resp.GetTemplateID(), resp.GetEnvdVersion()) + sb := newSandbox(config, api, resp.GetSandboxID(), resp.GetEnvdAccessToken(), resp.GetTemplateID(), resp.GetEnvdVersion()) return sb, nil } @@ -139,7 +139,8 @@ func applySandboxOptions(opts []SandboxOption) *sandboxOptions { } // newSandbox initializes a Sandbox with an envd client and management API. -func newSandbox(config *ConnectionConfig, api *SandboxApi, sandboxID, templateID, envdVersion string) *Sandbox { +func newSandbox(config *ConnectionConfig, api *SandboxApi, sandboxID, EnvdAccessToken, templateID, envdVersion string) *Sandbox { + config.AccessToken = EnvdAccessToken client := runtime.NewWithConfig(sandboxID, config.toEnvdConfig(sandboxID)) return &Sandbox{