From 6b95c8e7be440d43b6c2f31d3e398535eed9fd7e Mon Sep 17 00:00:00 2001 From: Marty McGuire Date: Wed, 4 Sep 2024 14:17:24 -0400 Subject: [PATCH] use redirectURI as clientID for CLI auth --- pkg/indieauth/auth.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/indieauth/auth.go b/pkg/indieauth/auth.go index 18d930b..9485f84 100644 --- a/pkg/indieauth/auth.go +++ b/pkg/indieauth/auth.go @@ -113,6 +113,8 @@ func GetEndpoints(me *url.URL) (Endpoints, error) { } // Authorize allows you to get the token from Indieauth through the command line +// NOTE: clientID is ignored. instead, use the auto-generated redirectURI, which +// IndieAuth clients should not attempt to fetch or parse. func Authorize(me *url.URL, endpoints Endpoints, clientID, scope string) (TokenResponse, error) { var tokenResponse TokenResponse @@ -130,7 +132,7 @@ func Authorize(me *url.URL, endpoints Endpoints, clientID, scope string) (TokenR redirectURI := fmt.Sprintf("http://%s/", local) state := util.RandStringBytes(16) - authorizationURL := CreateAuthorizationURL(*authURL, me.String(), clientID, redirectURI, state, scope) + authorizationURL := CreateAuthorizationURL(*authURL, me.String(), redirectURI, redirectURI, state, scope) log.Printf("Browse to %s\n", authorizationURL) @@ -175,7 +177,7 @@ func Authorize(me *url.URL, endpoints Endpoints, clientID, scope string) (TokenR reqValues.Add("grant_type", "authorization_code") reqValues.Add("code", code) reqValues.Add("redirect_uri", redirectURI) - reqValues.Add("client_id", clientID) + reqValues.Add("client_id", redirectURI) reqValues.Add("me", me.String()) req, err := http.NewRequest(http.MethodPost, endpoints.TokenEndpoint, strings.NewReader(reqValues.Encode()))