-
Notifications
You must be signed in to change notification settings - Fork 96
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
"Invalid authorization code": Access token is requested twice in a row, breaking the login flow #305
Comments
I have the same issue, can you share your code? |
I'm afraid I can't share my code because I've made other changes to it besides this. But as I said, for this issue all I've done was replace all text occurances of "index.php" with emptiness in the php files. |
@Kirill-TechHub - Late reply here but wanted to get something up about this. We made a number of changes recently (specifically #360) around how URLs are handled in the plugin. I don't know that it will specifically address this but version 3.5.0 of the plugin and later will include them. Talking through what's going on here ... it sounds like you've got a redirect loading somewhere during WP processing that's causing this to happen. Your best bet is a server-level one, if you need one, or none at all. Just with an OOTB WordPress install (latest, 4.9.2), I can type this: http://localhost:8080/index.php?auth0=1 ... and I'll get to the right place (meaning: Auth0 does it's processing and the filename is gone at the final URL). So, at this point, I'm not sure there's much we can do. We need to be specific about the links were using for callbacks and everything else, and we haven't seen this behavior in any testing. |
I think these recent changes do not affect this problem. I still have the issue described above. |
I found the issue in our case:
This empty catch block is maybe not the best idea. Especially, due to the fact that the missing redirect by auth0 causes the problem described above. I would propose to either leave the catch away or to error log and a proper redirect:
|
Good ... We don't want to blindly redirect like that, and in the case that something went wrong on our end, that's not going to work well. That said, there is clearly room for improvement here so I'll reopen, assign to myself, and take a look at it for an upcoming release. If inspiration strikes, please feel free to submit a PR! Also, when you have a sec, let me know the plugin you're using so I can test the behavior out. Thanks for the investigation and checking back in with what you found, we appreciate it! |
Pretty sure I have the same thing going on. From my own notes:
Annoyingly, something else in my code is stopping me just removing the |
A bit more info: this is happening to me because after successful code exchange, there is an exception thrown during the JWT decoding (there's no string to decode on https://github.com/auth0/wp-auth0/blob/master/lib/WP_Auth0_LoginManager.php#L245, which may well be the root cause of my problem). The exception bubbles up and causes the rediirection to the canonical URL, at which point the code exchange happens again and fails. |
I appreciate all the additional information here. This is absolutely on my radar to fix in the next minor release (maintenance one coming out next week first). |
Confirmed that @coperator's identification of the empty catch block is the culprit. If I |
WP_Auth0_LoginManager was not processing errors well, was poorly documented, and might have been improperly exposing error messages. Incoming URL param errors from Auth0 and configuration issues are caught earlier in the login process. Error message are not exposed to the user; instead they are logged for an admin. Thrown errors are standarized and listed in docblocks. Fixes #305
WP_Auth0_LoginManager was not processing errors well, was poorly documented, and might have been improperly exposing error messages. Incoming URL param errors from Auth0 and configuration issues are caught earlier in the login process. Error message are not exposed to the user; instead they are logged for an admin. Thrown errors are standarized and listed in docblocks. Fixes #305
WP_Auth0_LoginManager was not processing errors well, was poorly documented, and might have been improperly exposing error messages. Incoming URL param errors from Auth0 and configuration issues are caught earlier in the login process. Error message are not exposed to the user; instead they are logged for an admin. Thrown errors are standarized and listed in docblocks. Fixes #305
WP_Auth0_LoginManager was not processing errors well, was poorly documented, and might have been improperly exposing error messages. Incoming URL param errors from Auth0 and configuration issues are caught earlier in the login process. Error message are not exposed to the user; instead they are logged for an admin. Thrown errors are standarized and listed in docblocks. Fixes #305
Fixed in #409, merged into |
WP_Auth0_LoginManager was not processing errors well, was poorly documented, and might have been improperly exposing error messages. Incoming URL param errors from Auth0 and configuration issues are caught earlier in the login process. Error message are not exposed to the user; instead they are logged for an admin. Thrown errors are standarized and listed in docblocks. Fixes #305
I am using Wordpress Version 4.7.3, trying to install the official Auth0 plugin on it for the first time.
The problem is related to logging in as an Auth0 user. After a successful login Auth0 returns the user agent to https://site.com/index.php?auth0=1, which receives the auth code and uses it to get an access token - that's the usual pattern. In my case, however, the Wordpress site automatically redirects from /index.php to / (root), but only AFTER running the plugin token logic. So what actually happened was:
I don't know if this is a WP bug, perhaps related to a newer version of WP, but it is what it is. I fixed this by replacing every occurance of "index.php" in the source of the plugin with emptiness, and fixing the callbacks in Auth0 to redirect to /?auth0=1 instead of /index.php?auth0=1.
Maybe you can find a cleaner fix, perhaps a switch or an input field in the dashboard that lets the site owner choose the callback destination.
The text was updated successfully, but these errors were encountered: