dso0139 2016-11-28 17:02
浏览 17
已采纳

在CakePHP3中使用OAuth 2

I want to use an external Login (OAuth 2) with my CakePHP3 App. (The external Login need a Password and a Email). I never use an external Auth for my Applications (Everytime I use only my own Database with the Basic Auth of CakePHP3, so I have no clue what I should do)

In my AppController I write this :

 $this->loadComponent('Auth', [

 'authenticate' => [
   'Basic' => [
       'fields' => ['username' => 'email', 'password' =>'password'],
   ], ],

     'loginAction' => [
                'controller' => 'Users',
                'action' => 'login'
            ]
        ]);

$this->Auth->config('authenticate', 'OAuth2');

And in my OAuth2Authenticate.php

public function authenticate(Request $request, Response $response)
{
    $http = new Client();
    $response = $http->get('http:xxx/login', [], [
        'auth' => ['username' => 'email', 'password' => 'password']
    ]);
}

But I cannot get access to the User?

Is there any helpful Tutorial out there or Examples where I can learn, to build up a external Login to CakePHP3?

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现
  • ¥85 永磁型步进电机PID算法