Skip to content

Commit f00366a

Browse files
committed
fix: add EnvdAccessToken to runtime config for X-Access-Token auth
1 parent cddb434 commit f00366a

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

e2b/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ func (c *ConnectionConfig) toEnvdConfig(sandboxID string) *runtime.Config {
199199
RuntimePort: c.RuntimePort,
200200
APIKey: c.APIKey,
201201
RequestTimeout: c.RequestTimeout,
202+
RuntimeToken: c.AccessToken,
202203
}
203204

204205
// Pre-compute the full sandbox URL using the Protocol-aware logic so

e2b/sandbox.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func Create(ctx context.Context, template string, opts ...SandboxOption) (*Sandb
104104
return nil, fmt.Errorf("failed to create sandbox: %w", err)
105105
}
106106

107-
sb := newSandbox(config, api, resp.SandboxID, resp.TemplateID, resp.EnvdVersion)
107+
sb := newSandbox(config, api, resp.SandboxID, resp.EnvdAccessToken, resp.TemplateID, resp.EnvdVersion)
108108
return sb, nil
109109
}
110110

@@ -125,7 +125,7 @@ func Connect(ctx context.Context, sandboxID string, opts ...SandboxOption) (*San
125125
return nil, fmt.Errorf("failed to connect to sandbox: %w", err)
126126
}
127127

128-
sb := newSandbox(config, api, resp.GetSandboxID(), resp.GetTemplateID(), resp.GetEnvdVersion())
128+
sb := newSandbox(config, api, resp.GetSandboxID(), resp.GetEnvdAccessToken(), resp.GetTemplateID(), resp.GetEnvdVersion())
129129
return sb, nil
130130
}
131131

@@ -139,7 +139,8 @@ func applySandboxOptions(opts []SandboxOption) *sandboxOptions {
139139
}
140140

141141
// newSandbox initializes a Sandbox with an envd client and management API.
142-
func newSandbox(config *ConnectionConfig, api *SandboxApi, sandboxID, templateID, envdVersion string) *Sandbox {
142+
func newSandbox(config *ConnectionConfig, api *SandboxApi, sandboxID, EnvdAccessToken, templateID, envdVersion string) *Sandbox {
143+
config.AccessToken = EnvdAccessToken
143144
client := runtime.NewWithConfig(sandboxID, config.toEnvdConfig(sandboxID))
144145

145146
return &Sandbox{

0 commit comments

Comments
 (0)