Not Redirected Back To Application After Successful Login

Trying to add just login to single php file (index.php) application. When going to my application’s URL, it successfully redirects to the Auth0 login page. When I enter the creds of the user I created and click the Continue button, it seems to just reload the Auth0 login page. If I enter the wrong creds, I get an error so at least that’s working. I have the Callback URL set to my application’s URL in my application settings. I also have it set (dynamically) in my code:




use Auth0\SDK\Auth0;
use Auth0\SDK\Configuration\SdkConfiguration;

$configuration = new SdkConfiguration(
   domain: '',
   clientId: '[OMMITED]',
   clientSecret: '[OMMITED]',
   redirectUri: 'https://' . $_SERVER['HTTP_HOST'] . '/',
   cookieSecret: '[OMMITED]'

$sdk = new Auth0($configuration);


$session = $sdk->getCredentials();
$authenticated = $session !== null;
if(!$authenticated) {
   header(sprintf('Location: %s', $sdk->login()));

// Run index.php if authenticated...


I looked through the documentation, searched this forum, Googled and still can’t figure why it’s not returning to my application’s URL after logging in.

  • Gavin

Getting closer to a solution. I copied the php code I had in index.php (see above) to a login.php file I created, removed the the “header(sprintf(‘Location: %s’, $sdk->login()));” part from index.php and retested. I found that:

  1. Successful Auth0 login is redirecting back to my index.php file.
  2. $sdk->getCredentials() in index.php returns null.
  3. Two parameters & values are being appended to the URL in my browser on redirection to index.php, code and state.

I’ve searched through this forum and Googled for what would make getCredentials() return null and haven’t found anything useful. What are those returned params for? What do I do with them?

  • Gavin