我试图连接基本的PHP/JS Auth0集成,但是"userInfo“调用总是不返回任何东西,即使是一个空的array.Here也不是我设置它的方式。
首先,非常简单的“登录”页面。
<?php
require_once 'config.php';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Testing Auth0 PHP</title>
</head>
<body>
<script src="https://cdn.auth0.com/w2/auth0-widget-5.2.min.js"></script>
<script>
var widget = new Auth0Widget({
domain: "<?php echo $auth0_cfg['domain'] ?>",
clientID: "<?php echo $auth0_cfg['client_id'] ?>",
callbackURL: "<?php echo $auth0_cfg['redirect_uri'] ?>",
callbackOnLocationHash: true
});
</script>
<button onclick="widget.signin()">Login</button>
</body>
</html>然后是回调页面,这就是用户被Auth0自动重定向的地方(这样我就知道这个部分是正常工作的)。
<?php
require_once 'vendor/autoload.php';
require_once 'config.php';
use Auth0SDK\Auth0;
$auth0 = new Auth0(array(
'domain' => $auth0_cfg['domain'],
'client_id' => $auth0_cfg['client_id'],
'client_secret' => $auth0_cfg['client_secret'],
'redirect_uri' => $auth0_cfg['redirect_uri']
));
$userInfo = $auth0->getUserInfo();
if (!$userInfo) {
print 'No user';
} else {
print 'User';
}url中包含令牌信息,并且始终如下所示:
http://localhost/hack/internal.php#access_token=zF...7jWOb&id_token=eyJ0eXAiOi...fvyW8P0DH4k&token_type=bearer我试着查找了一些关于这方面的Auth0教程,但是看不到我遗漏了什么。以前有熟悉Auth0的人遇到过这种情况吗?
发布于 2014-09-14 08:09:50
GetUserInfo是一个服务器到服务器的调用(从你的web服务器到auth0.com)。有时(特别是在公司环境中),来自非用户进程的流量会被阻塞。
我怀疑是这样的,因为所有其他交互都工作得很好(但它们通过浏览器,而不是web服务器)。
您可以尝试通过不在代理后面的网络快速连接。
此外,我使用上面提供的access_token (我删除了BTW,因为它是敏感信息)测试了您的帐户的userinfo端点,它工作得很好。您可以通过Postman或类似工具自己测试此功能。
(有关详细信息,请在eugeniop AT auth0.com上Ping我)
https://stackoverflow.com/questions/25828580
复制相似问题