SDK: auth0-php
SDK Version: ^8.0
Platform Version: PHP 8.0
I was going along the quick start for setting up the SDK in order to apply a Discord authenticator to my PHP site. For now, though, I was simply setting up an empty file in accordance with the guide.
I do get the authentication through, but once I return with the callback I do get the following error message:
Fatal error: Uncaught Auth0\SDK\Exception\StateException: Missing code in .../vendor/auth0/auth0-php/src/Exception/StateException.php:30
Stack trace: #0 ../vendor/auth0/auth0-php/src/Auth0.php(317): Auth0\SDK\Exception\StateException::missingCode() #1 ../user2.php(69): Auth0\SDK\Auth0->exchange('http://127.0.0....')
Still, I followed the guide from start to finish. I even copy-pasted the code to make sure I didnāt make any typos.
- Code Snippets/Error Messages/Supporting Details/Screenshots:
As far as I could see, the issue comes in my ROUTE_URL_CALLBACK that I defined earlier.
I checked the data and naming but all seem to be correct.
Hi @JoeyJaySWE,
A āmissing codeā error occurs when the ?code parameter was not returned or is not accessible to your applicationās callback from the authentication flow, for whatever reason. From your callback page, can you check what parameters your user is being returned to your application in the URL with?
- You should have ?code=ā¦ and ?state=ā¦ query parameters in your callback URL after a successful authentication flow.
- If there is an ?error parameter present instead, that may give you a hint as to whatās going wrong.
- From your Auth0 Dashboard, check your logs and ensure the authentication flow is actually going through successfully.
1 Like
Turns out it didnāt go through properly.
I get a failed login attempt with āinvalid_requestā.
I still managed to get the Discord connection showing and I get to the stage where it finds my account and I can press Authorize, but once I do it fails.
I canāt seem to find any mentioning of what has failed, I only got a parameter saying invalid_request and a state in hexadecimal.
Anything unusual in your Auth0 dashboard logs? Can find them under Monitoring > Logs on the sidebar
1 Like