Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 拉维尔社交名流_Laravel_Oauth 2.0 - Fatal编程技术网

Laravel 拉维尔社交名流

Laravel 拉维尔社交名流,laravel,oauth-2.0,Laravel,Oauth 2.0,我想将Socialite集成到基于Laravel的CMS中,我试图弄清楚,如果客户id和客户机密保存在数据库中,我将如何启动Socialite发送请求 从文档的基本用法 return Socialize::with('github')->redirect(); 和凭据保存在config/services.php中 /** * Create an instance of the specified driver. * * @return \Laravel\Socialite\Two\

我想将Socialite集成到基于Laravel的CMS中,我试图弄清楚,如果客户id和客户机密保存在数据库中,我将如何启动Socialite发送请求

从文档的基本用法

return Socialize::with('github')->redirect();
和凭据保存在config/services.php中

/**
 * Create an instance of the specified driver.
 *
 * @return \Laravel\Socialite\Two\AbstractProvider
 */
protected function createGithubDriver()
{
    $config = $this->app['config']['services.github'];

    return $this->buildProvider(
        'Laravel\Socialite\Two\GithubProvider', $config
    );
}

我想在工厂调用时定义$this->app['config']你能不能创建一个中间件类,将其应用到相关路由,然后使用以下方法设置配置:

$v = Auth::user()->github // or however you work it out, not sure how you've got it stored
Config::set('services.github', $v);

像这样设置config只为当前请求设置它

您应该能够扩展
createGithubDriver()
method从数据库中提取数据,或者您可以在调用此函数之前在应用程序的其他位置放置一些逻辑来设置配置值。最后一个方法将是一个完美的解决方案,可以在自定义服务提供商中尝试将逻辑添加到引导方法,这可能会奏效(Laravel 5)使用.evn文件来存储这些信息不是更好吗?我认为这样更安全。(env文件作为laravel 5的一部分引入)