Hi,
I have a little problem … I made a web app in PHP. I tried to made a login system with auth0. But when i call my callback page my $auth0->getUser() return null. And I don’t know why ?
Can you help me ?
My index.php :
<?php
session_start();
require_once __DIR__ . '/inc/Github/auth0/vendor/autoload.php';
require_once('./inc/Github/test.php');
include_once('inc/header.php');
if(isset($_GET"page"])) {
switch ($_GET'page']) {
case "home":
include("pages/home.php");
break;
case "dashboard":
include("pages/dashboard.php");
break;
default:
include("pages/404.php");
break;
}
}else{
include("pages/home.php");
}
include('inc/footer.php');
?>
My test.php
<?php
use Auth0\SDK\Auth0;
$auth0 = new Auth0(array(
'domain' => 'cisme.eu.auth0.com',
'client_id' => 'BGpiP70lDmLaXXTiVF1hOFbRRRQuDQAX',
'client_secret' => 'sHC_VgwxESF2dC0_uBijsDu ....',
'redirect_uri' => 'http://localhost/ManageGituhub/dashboard'
));
**My login page (header) **
<!DOCTYPE html>
<?php include_once('./inc/variables.php');?>
<html>
<head>
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="css/materialize.css" media="screen,projection"/>
<script src="https://cdn.auth0.com/js/lock/10.15/lock.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<nav>
<div class="nav-wrapper container">
<a href="<?php echo BASE_URL;?>" class="brand-logo"><?php echo $siteName ?></a>
<a href="#" data-activates="mobile-demo" class="button-collapse"><i class="material-icons">menu</i></a>
<ul class="right hide-on-med-and-down">
<li><a href="sass.html">A propos</a></li>
<li><a class="modal-trigger waves-effect waves-dark btn red darken-1" href="#modalLogin" onclick="lock.show();">Connexion</a></li>
<li><a class="modal-trigger waves-effect waves-dark btn red darken-1" href="#modalSignIn">Inscription</a></li>
</ul>
<ul class="side-nav" id="mobile-demo">
<li><a href="sass.html">A propos</a></li>
<li><a class="modal-trigger waves-effect waves-dark btn red darken-1" data-activates='dropdown1' href="#modalLogin">Connexion</a> </li>
<li><a class="waves-effect waves-dark btn red darken-1">Inscription</a></li>
</ul>
</div>
</nav>
<?php include_once('./inc/modalSignIn.php');?>
<?php include_once('./inc/modalLogin.php');?>
<?php require_once ('./inc/Github/php-github-api-master/vendor/autoload.php'); ?>
My callback.php
<?php
var_dump($_SESSION);
$userInfo = $auth0->getUser();
var_dump($auth0->getUser());
//$userInfo = $auth0->getUser();
My script.js
var lock = new Auth0Lock('BGpiP70lDmLaXXTiVF1hOFbRRRQuDQAX', 'cisme.eu.auth0.com', {
auth: {
redirectUrl: 'http://localhost/ManageGituhub/dashboard',
responseType: 'code',
params: {
scope: 'openid email' // Learn about scopes: https://auth0.com/docs/scopes
}
}
});