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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序