小编Pat*_*raj的帖子

尝试实现 OAuth2 服务器并集成到 ThingsBoard 平台

我正在尝试在 ThingsBoard 实例中实现自定义 OAuth2 实现,因为我已经在 php 中实现了 OAuth2 服务器

https://github.com/bshaffer/oauth2-demo-php

http://brentertainment.com/oauth2/

按照他们的 bshaffer 演示,它工作正常,当我将它与第三方应用程序 thingboard 实例集成时,第一步工作正常,直到身份验证,然后它重定向到登录页面,指出 Oauth2 错误,但不知道它是什么,这里是示例OAuth2 服务器的 URL 和响应

http://34.226.xxx.xx/oauth2/web/lockdin/authorize

http://34.226.xxx.xx/oauth2/web/lockdin/token

http://34.226.xxx.xx/oauth2/web/lockdin/resource

步骤1:

http://34.226.xxx.xx/oauth2/web/lockdin/authorize?response_type=code&client_id=demoapp&scope=email&state=2r3TIvWotKyjXJ3Nzef-DA_0EZdJFdMm_bO2wCF7S8%3D&redirect_uri=https://thingsboard.io/login/oauth2/code/

第2步:

授权发生后,成功响应会发送回

https://thingsboard.io/login/oauth2/code/?code=something&state=2r3TIvWotKyjXJ3Nzef-DA_0EZ-dJFdMm_bO2wCF7S8%3D

在此之后它失败了

我已经测试了此后手动生成令牌的步骤及其工作正常

http://34.226.xxx.xx/oauth2/web/lockdin/token它给了我回应

{
    "access_token": "4a01f8b9e8548420425c8f335eda2a3dbde7ef75",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "email",
    "refresh_token": "ccbb9b8a03949e0e013acdb7f8e79426aa1a0a58"
}
Run Code Online (Sandbox Code Playgroud)

和资源 api 我得到以下响应

{
      "email":"test@gmail.com",
      "firstName":"Dave",
      "lastName":"Johnson",
      "profile":1828838378
}
Run Code Online (Sandbox Code Playgroud)

对此的任何帮助将非常感激

编辑:请找到终点的来源

授权.php

namespace OAuth2Demo\Server\Controllers;
use Silex\Application;
class Authorize
{
    public static function addRoutes($routing)
    {
        $routing->get('/authorize', array(new self(), 'authorize'))->bind('authorize');
        $routing->post('/authorize', array(new self(), 'authorizeFormSubmit'))->bind('authorize_post');
    }
  
    public …
Run Code Online (Sandbox Code Playgroud)

php oauth-2.0 thingsboard

5
推荐指数
1
解决办法
863
查看次数

如何从多维数组中获取所有值

海先来看看这个阵列,

Array
(
    [0] => Array
        (
            [id] => 4
            [parent_id] => 3
            [children] => Array
                (
                    [0] => Array
                        (
                            [id] => 7
                            [parent_id] => 4
                            [children] => Array
                                (
                                    [0] => Array
                                        (
                                            [id] => 6
                                            [parent_id] => 7
                                            [children] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [id] => 2
                                                            [parent_id] => 6
                                                        )

                                                )

                                        )

                                )

                        )

                )

        )

    [1] => Array
        (
            [id] => 5
            [parent_id] => 3
        )

)
Run Code Online (Sandbox Code Playgroud)

我需要一个所有id [IE:4,7,6,2,5]的输出是我需要的东西的理想结果

foreach ($tree as $j) …
Run Code Online (Sandbox Code Playgroud)

php arrays multidimensional-array

2
推荐指数
1
解决办法
55
查看次数