Claude Code module authentication with Claude Code Subscription

I've a Claude Code Max Subscription, I want to use that instead of Console API KEY, how can I do that cleanly, Now I'm doing it by mounting volumes.
6 Replies
Codercord
Codercord2w ago
Codercord
Codercord2w ago
<#1404654368745193492>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
matifali
matifali2w ago
Hi @Riajul Islam Can you explain your current workaround? And what do you expect the module to improve to better support Claude Max users
Riajul Islam
Riajul IslamOP2w ago
Initially I've tried mounting ~/.claude.json and ~/.claude/.credentials.json to a temp location in container and then on startup script I've copied that mounted files to the expected folder inside the container, and it was working. And then I found another challenge where these credential files from host machine is not long lived, they need to get synced every ~6 hours. And then I noticed there was already a way to generate long lived oauth token using the claude setup-token command, which I used to generate a long lived token, which I injects into the container with environment variable named: CLAUDE_CODE_OAUTH_TOKEN I was using the tasks-docker template to test it out, and it would have been better beside having anthropic_api_key variable for console API key injection, there was a variable for claude_code_oauth_token. In my case I've modified the main.tf to use the new variable, like this:
variable "claude_code_oauth_token" {
type = string
description = "Generate one using `claude setup-token` command"
sensitive = true
}
resource "coder_env" "claude_code_oauth_token" {
agent_id = coder_agent.main.id
name = "CLAUDE_CODE_OAUTH_TOKEN"
value = var.claude_code_oauth_token
}
variable "claude_code_oauth_token" {
type = string
description = "Generate one using `claude setup-token` command"
sensitive = true
}
resource "coder_env" "claude_code_oauth_token" {
agent_id = coder_agent.main.id
name = "CLAUDE_CODE_OAUTH_TOKEN"
value = var.claude_code_oauth_token
}
Note: both (API Key, Oauth Token) cannot exist at the same time.
matifali
matifali6d ago
Good feedback if you like we welcome a PR to add this functionality to the module on registry so that others can benefit from it. Glad to know the workaround
Phorcys
Phorcys4d ago
@Riajul Islam ^

Did you find this page helpful?