-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add OIDC Twitter provider configuration #23593
Comments
/cc @pedroigor |
OK, I tried it. Doesn't work. Twitter refuses to tell me why not, which isn't helpful. My config:
The URI I land on:
Twitter only tells me:
Which is not helpful |
@FroMage Can you please try make it a public resource |
If that returns an internal error then we need to find a way to report the issue to Twitter Oauth2 developers. FYI, the integration PKCE tests in Quarkus run directly against Keycloak which also supports PKCE, so we do not assume it works by running wiremock tests |
@FroMage Also, the error message might contain some hints that the Renarde app might not be configured correctly in Twitter, please check the redirect_uris match, etc |
I got further this time. Turns I forgot my redirect URI from the config. Now it doesn't work because the scope is set to quarkus.oidc.twitter.authentication.scopes=offline.access The duplicate |
I can fix this manually by repeating the redirect with the proper scopes, but then I get the infamous 401 when I'm back on Quarkus after Twitter authorized me, and I still have to use a debugger because Quarkus doesn't log anything useful. This is driving me crazy BTW, we absolutely must fix this lack of logging. |
I can't even replay the failure in a debugger because OIDC clears the auth cookie:
Making this just this much harder to debug, because I don't even know where to step to figure out why the hell OIDC rejects this callback. |
Found the place to step in, getting this swallowed exception |
OK, so this second one seems to stem from
Here's my travel so far: Got to Twitter via:
Got back via:
Then, OIDC made a POST to https://api.twitter.com/2/oauth2/token:
Got back a 400:
Now, I'm not sure what they mean by |
I found how to test it, apparently the code verifier must be hashed with sha-256 to get the code challenge. But if I use https://gchq.github.io/CyberChef/#recipe=From_Base64('A-Za-z0-9-_',true)SHA2('256',64,160)From_Hex('Auto')To_Base64('A-Za-z0-9-_')&input=aXRhWUY3S0lWdE1nR25yRGFQeHQyYTU0bGlKTFc2OFM0LUE1M2xkb0VpNA I don't see I'm a bit at a loss what goes wrong then. |
Thanks @FroMage, I'll have a look asap (the issue about improving the debugging experience is open so will be addressed a bit later too :-) ) |
gives This is the code used in
|
They should be referring to |
@FroMage See https://twittercommunity.com/t/value-passed-for-the-authorization-code-was-invalid/164422, looks like the |
I know it doesn't work without breakpoints, because I get a 401 with no info. Now, it's possible that with breakpoints it fails for a different reason, such as the timeout. You didn't explain why the CyberChef gives a different result than the OIDC code we have. Hopefully it's me who misconfigured it, but I find it suspect that I can't get the same result there as we do. |
@FroMage Hi, looks like in your recipe you have the input Base64 URL decoded first, while Quarkus takes the bytes directly from the Base64 URL encoded representation. Can you please update that code where you see the error message being swallowed to log it and see what is actually reported ? |
Well I can't know which error message is being swallowed if I don't debug it. |
OK, you're right, that was my mistake, and indeed it looks correct. |
@FroMage I see in the code that there are only 2 places where no debug messages are done, here and here, the second one happens already after the code flow has completed, during the verification one, but it does look like the first one explains what is happening,
|
@FroMage Sorry, I see you are setting it in your config... |
So, if I remove the
See how not helpful this is? |
This is already a different error that I was getting, it seems |
@FroMage Looks like some progress, so this 403 is coming from Twitter if it is reported by OidcProviderClient |
I agree the debugging experience is poor, no doubt. Will be addressed. Can you check, where is it coming from, perhaps when trying to get UserInfo ? if yes, then it is nearly 100% a scope setup issue |
Set the only breakpoint in OidcProviderClient, getUserInfo |
Can it be while getting user info? I thought this was from the token exchange |
@FroMage Yes, you are right, it does look like the access token Twitter gives back does not have enough permissions in it - which is a scope related problem |
It is the damn UserInfo, you're right, now I've added debug logging I can see it. |
Yeah, docs say I need more scopes:
And finally I'm getting further. Now it looks like the exception is in my camp. Thanks. I'll report back when I get it to work with the changes required. |
@FroMage Great stuff, so re the |
It looks like twitter API V2 doesn't give me access to the user's email. I need the V1.1 API for that, which requires elevated access. Why can't things be simple… |
But the V1.1 API requires OAuth 1.0a, do we support that? |
@FroMage Sadly no, Lets add a twitter provider configuration to |
@FroMage Once they add a scope for the email then we will update this configuration |
See #24774 |
Description
Now that PKCE is supported it should be possible to add a
twitter
configuration, Steph, please verify and add it once it works for you, thankshttps://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code
Implementation ideas
No response
The text was updated successfully, but these errors were encountered: