Skip to content

Commit ac1dd56

Browse files
committed
fix: URL-encode OAuth params (spaces in scope broke the URL)
1 parent c31a65e commit ac1dd56

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

auth.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"io"
1111
"net"
1212
"net/http"
13+
"net/url"
1314
"os"
1415
"os/exec"
1516
"path/filepath"
@@ -264,16 +265,18 @@ func Login() error {
264265
}()
265266
defer server.Close()
266267

267-
// Build auth URL — this opens the Codebase login page
268-
// The login page handles the actual authentication (email, Google, GitHub, wallet)
269-
// and then redirects to our authorize endpoint which generates the code
270-
authURL := fmt.Sprintf("%s/login?oauth=true&client_id=%s&redirect_uri=%s&code_challenge=%s&code_challenge_method=S256&scope=%s&state=%s",
268+
// Build auth URL with proper URL encoding
269+
authParams := url.Values{}
270+
authParams.Set("oauth", "true")
271+
authParams.Set("client_id", oauthClientID)
272+
authParams.Set("redirect_uri", redirectURI)
273+
authParams.Set("code_challenge", codeChallenge)
274+
authParams.Set("code_challenge_method", "S256")
275+
authParams.Set("scope", oauthScopes)
276+
authParams.Set("state", state)
277+
authURL := fmt.Sprintf("%s/login?%s",
271278
strings.TrimSuffix(oauthBaseURL, "/api"),
272-
oauthClientID,
273-
redirectURI,
274-
codeChallenge,
275-
oauthScopes,
276-
state,
279+
authParams.Encode(),
277280
)
278281

279282
fmt.Println("Opening browser for authentication...")

0 commit comments

Comments
 (0)