简体   繁体   English

Auth0 getUseInfo空白

[英]Auth0 getUseInfo blank

I was trying to hook up basic PHP/JS Auth0 integration, yet the "userInfo" call always returns nothing, not even an empty array.Here is how I have it setup. 我试图连接基本的PHP / JS Auth0集成,但是“ userInfo”调用始终不返回任何内容,甚至不返回空数组。这是我设置的方式。

First, the very simple "login" page. 首先,非常简单的“登录”页面。

<?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>

And then the callback page, that is where the user is redirected automatically by Auth0 (so I know that part is working). 然后是回调页面,该页面由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';
}

The url has the token information in it and always looks like: 网址中包含令牌信息,并且始终如下所示:

http://localhost/hack/internal.php#access_token=zF...7jWOb&id_token=eyJ0eXAiOi...fvyW8P0DH4k&token_type=bearer

I've tried looking up some Auth0 tutorials on this, but can't see what I'm missing. 我尝试查找有关此内容的一些Auth0教程,但看不到我所缺少的内容。 Has anybody who is familiar with Auth0 run into this before? 以前有谁熟悉Auth0吗?

Are you running the sample from behind a proxy? 您是从代理后面运行示例吗? GetUserInfo is a server to server call (from your web server to auth0.com). GetUserInfo是服务器到服务器的调用(从您的Web服务器到auth0.com)。 Sometimes (especially in corp environments), traffic is blocked from non user processes. 有时(尤其是在公司环境中),禁止非用户进程访问流量。

I suspect this is the case, because all other interactions work well (but they go through the browser, not the web server). 我怀疑是这种情况,因为所有其他交互都可以正常工作(但它们通过浏览器而不是Web服务器)。

You can try this quickly connecting through a network that is not behind a proxy. 您可以尝试通过不位于代理后面的网络快速连接。

Also, I tested the userinfo endpoint for your account with the access_token you supplied above (which I deleted BTW, as it is sensitive info), and it works just fine. 另外,我使用上面提供的access_token测试了您帐户的userinfo端点(我删除了BTW,因为它是敏感信息),并且工作正常。 You can test this yourself from a tool like Postman or equivalent. 您可以使用Postman之类的工具或类似工具自己进行测试。

(Ping me on eugeniop AT auth0.com for details) (有关详细信息,请在eugeniop AT auth0.com上向我发送邮件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM