Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argocd login --sso oauth2: cannot fetch token: 401 Unauthorized #12124

Open
skan-splunk opened this issue Jan 25, 2023 · 11 comments
Open

argocd login --sso oauth2: cannot fetch token: 401 Unauthorized #12124

skan-splunk opened this issue Jan 25, 2023 · 11 comments
Labels
bug/in-triage This issue needs further triage to be correctly classified bug Something isn't working component:cli Affects the Argo CD CLI component:sso Issues related to Argo CD configurations type:bug

Comments

@skan-splunk
Copy link

Describe the bug

Attempting to use argocd CLI and authenticating with argocd login <server> --sso and Okta SSO, and receiving the following output and error in the CLI:

WARN[0005] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.
Opening browser for authentication
INFO[0007] RequestedClaims: map[groups:essential:true ]
Performing authorization_code flow login: https://{blahhost}&code_challenge_method={blahhash}&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2Fauth%2Fcallback&response_type=code&scope=openid+profile+email+groups+offline_access&state={blah}
FATA[0027] oauth2: cannot fetch token: 401 Unauthorized
Response: {"error":"invalid_client","error_description":"Client authentication failed. Either the client or the client credentials are invalid."}

After Okta authentication, I get an accepted callback to the URL:http://localhost:8085/auth/callback?code={blah}&state={blah} which has the error:

oauth2: cannot fetch token: 401 Unauthorized
Response: {&#34;error&#34;:&#34;invalid_client&#34;,&#34;error_description&#34;:&#34;Client authentication failed. Either the client or the client credentials are invalid.&#34;}

Authenticating directly into ArgoCD UI works fine, additionally able to authenticate using --auth-token flag.
Expected behavior

Run argocd login <server> --sso, authenticate via okta SSO login, success

Version
ArgoCD v2.5.3

@skan-splunk skan-splunk added the bug Something isn't working label Jan 25, 2023
@ziouf
Copy link

ziouf commented Feb 7, 2023

It is still an issue on my side with v2.6.0

@icecoffee531
Copy link
Contributor

When I set the oidc provider config to public:true it works perfectly (in my case using keycloak)

@jfdoube
Copy link

jfdoube commented Apr 19, 2023

Still an issue here as well

@eranreshef-starkware
Copy link

Ran into this also.
@icecoffee531 I tried your suggestion and it didn't work for me. Did you do anything else I might have missed?

@billabongrob
Copy link

We've attempted to do the same with Okta and were running into the same issues even with public: true

Setting the cliClientID helped us, FWIW.

    # Some OIDC providers require a separate clientID for different callback URLs.
    # For example, if configuring Argo CD with self-hosted Dex, you will need a separate client ID
    # for the 'localhost' (CLI) client to Dex. This field is optional. If omitted, the CLI will
    # use the same clientID as the Argo CD server
    cliClientID: vvvvwwwwxxxxyyyyzzzz

ref

@stefanandres
Copy link

stefanandres commented Sep 13, 2023

@billabongrob

Setting the cliClientID helped us, FWIW.

What did you do on Okta for this? Did you create another Okta app with localhost as callback url or something?
It would be great if you could elaborate on what exactly you needed to do to get it working.

@billabongrob
Copy link

Absolutely, sorry for being vague - end of the day response! 😃
Yes, we created a Native type OIDC Okta app for the CLI and set it to use Authorization Code + PKCE. The sign in redirect URI was http://localhost:8085/auth/callback and the sign out redirect URI was http://localhost:8085

@eranreshef-starkware
Copy link

Thanks @billabongrob your solution worked for me too 🎉

@zentavr
Copy link

zentavr commented Jul 3, 2024

@billabongrob I have Keykloak at my side and adding Valid redirect URIs.

Also I'd adjusted Web origins:

Other settings are the next:
Знімок екрана 2024-07-03 о 04 05 44

There is still the issue:

$ argocd login argocd-k8s-production.example.io --sso --name argocd-k8s-production
WARN[0003] Failed to invoke grpc call. Use flag --grpc-web in grpc calls. To avoid this warning message, use flag --grpc-web.
Opening browser for authentication
Performing authorization_code flow login: https://sso.example.io/realms/Example/protocol/openid-connect/auth?access_type=offline&client_id=argocd-production-k8s-shared&code_challenge=iI8mfDBZNByRXPnZUruwZhJ5oLHnZouqrumI1KWSjYs&code_challenge_method=S256&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2Fauth%2Fcallback&response_type=code&scope=openid+profile+email+groups+offline_access&state=vHlgeXwhAfriUvkGtFrWCPVK
FATA[0013] oauth2: "unauthorized_client" "Invalid client or Invalid client credentials"

Have that after entering login+password in the pop up browser window.

Maybe this might be an issue: #10029 (comment)

@zentavr
Copy link

zentavr commented Jul 3, 2024

So the reply to my question above:
#10029 (comment)

For keykloak this needs to be done:

Знімок екрана 2024-07-03 о 04 14 13

Client authentication: OFF

@alexmt alexmt added bug/in-triage This issue needs further triage to be correctly classified component:cli Affects the Argo CD CLI component:sso Issues related to Argo CD configurations type:bug labels Jul 3, 2024
@albundy83
Copy link
Contributor

albundy83 commented Nov 14, 2024

I have tried and I can login successfully.
I have an issue and I see the error invalid_request: Missing parameter: code_challenge_method after 5 minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/in-triage This issue needs further triage to be correctly classified bug Something isn't working component:cli Affects the Argo CD CLI component:sso Issues related to Argo CD configurations type:bug
Projects
None yet
Development

No branches or pull requests

10 participants