Skip to content

int128 / kubelogin - AADSTS900144: The request body must contain the following parameter: 'client_id' #734

Open
@markush81

Description

error: get-token: authentication error: authcode-browser error: authentication error: authorization code flow error: oauth2 error: could not exchange the code and token: oauth2: "invalid_request" "AADSTS900144: The request body must contain the following parameter: 'client_id'. Trace ID: ... Correlation ID: ...Timestamp: 2024-08-02 12:27:19Z" "https://login.windows.net/error?code=900144"

It seems that Azure does need some parameters, which others don't ... with this two lines patched, this issue would be solved.

int128/kubelogin#536

diff --git a/oauth2.go b/oauth2.go
index 09f6a49..591a4d9 100644
--- a/oauth2.go
+++ b/oauth2.go
@@ -224,6 +224,7 @@ func (c *Config) Exchange(ctx context.Context, code string, opts ...AuthCodeOpti
        v := url.Values{
                "grant_type": {"authorization_code"},
                "code":       {code},
+               "client_id":     {c.ClientID},
        }
        if c.RedirectURL != "" {
                v.Set("redirect_uri", c.RedirectURL)
@@ -280,6 +281,7 @@ func (tf *tokenRefresher) Token() (*Token, error) {
        tk, err := retrieveToken(tf.ctx, tf.conf, url.Values{
                "grant_type":    {"refresh_token"},
                "refresh_token": {tf.refreshToken},
+               "client_id":     {tf.conf.ClientID},
        })
 
        if err != nil {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions