Laravel:使用Guzzle使用自定义Passport登录的解决方案

乔治·瓦伦丁

我正在尝试做一个路由/ api / user / signin和控制器内部以将Guzzle HTTP发布到/ oauth / token很好,但是服务器停滞了。我发现了这个:https : //stackoverflow.com/a/46350397/5796307

那我该怎么办?如何在没有HTTP请求的情况下调用/ oauth / token?我可以“创建”请求类并传递给该函数吗?

DigitalDrifter

无需使用Guzzle或file_get_contents,从控制器功能内创建一个新的HTTP请求,并将其路由通过框架:

public function signin (Request $request) {

    // get an appropriate client for the auth flow
    $client = Client::where([
        'password_client' => true,
        'revoked'         => false
    ])->first();

    // make an internal request to the passport server
    $tokenRequest = Request::create('/oauth/token', 'post', [
            'grant_type'    => 'password',
            'client_id'     => $client->id,
            'client_secret' => $client->secret,
            'username'      => $request->input('email'),
            'password'      => $request->input('password')
    ]);

    // let the framework handle the request
    $response = app()->handle($tokenRequest);

    // get the token from the response if authenticated, other wise redirect to login
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用自定义深度测试的深度解决方案

在解决方案上使用msbuild在某些项目上调用自定义目标

这是使用Couchbase解决方案的.NET自定义角色提供程序的合理方法吗?

自定义解决方案的Visual Studio配色方案

如何使用Visual Studio 2019在解决方案中为多个项目指定自定义代码分析规则集?

使用循环绘制具有自定义线格式的大型数据集的强大解决方案

Git合并冲突自定义自动解决方案

如何创建自定义动态DNS解决方案?

自定义 Visual Studio 解决方案

实施自定义Int + Range List解决方案

如何扩展自定义解决方案Xamarin的按钮

MVC 6自定义Taghelper验证-解决方案

Laravel Auth登录解决方案

需要有效的解决方案才能在自定义应用程序中使用Android模式锁定屏幕(而不是源代码重定向)

CSceneBuilder 2.0不包括自定义控件,但是1.0和1.1不能与JDK 8.0一起使用,什么解决方案?

Laravel 自定义登录:使用 MD5 hasing

使用@DataJpaTest设置自定义方案

UriComponentsBuilder使用自定义方案截断

如何为自定义日志记录解决方案正确创建性能测试?

解决方案预设的项目文件上的自定义属性

自定义解决方案不存在于整个重新引导中

将自定义项模板添加到 Visual Studio 解决方案

同一解决方案的其他项目中的自定义追加程序

无法导入Dynamics CRM 2013自定义代码验证工具解决方案

巴基斯坦的Chrome扩展程序自定义付款解决方案?

如何为托管解决方案添加自定义站点地图区域/组/子区域?

HTML选择元素-自定义默认值?(跨浏览器解决方案)

将此自定义回合转换为更数学友好的解决方案

自定义实体未显示在默认解决方案屏幕中 - Dynamics CRM 2013