默认情况下,Passport 发放的访问令牌是永久有效的,不需要刷新。但是如果你想自定义访问令牌的有效期,可以使用 tokensExpireIn 和refreshTokensExpireIn 方法。上述两个方法同样需要在 AuthServiceProvider 的boot 方法中调用:use Carbon\Carbon;/** * Register any authentication / authorization services. * * @return...
API Authentication (Passport) - Laravel中文网 , laravel中文文档。Laravel 是一个具有表现力、优雅语法的 Web 应用程序框架. Laravel 是构建现代全栈 Web 应用程序的最佳选择.
* Register any authentication / authorization services. * * @return void*/publicfunctionboot() {$this->registerPolicies(); Passport::routes(); Passport::tokensExpireIn(now()->addDays(30)); //这里设置为30天过期 Passport::refreshTokensExpireIn(now()->addDays(30)); } } 3. config/auth.php...
Laravel makes API authentication a breeze using Laravel Passport, which provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. Passport is built on top of the League OAuth2 server that is maintained by Andy Millington and Simon Hamp....
* Register any authentication / authorization services. * * @return void*/publicfunctionboot() {$this->registerPolicies(); Passport::routes();//注册passport路由 //令牌的有效期Passport::tokensExpireIn(Carbon::now()->addDays(15)); Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));...
如果用户未进行身份验证,Laravel 将抛出AuthenticationException。 This exception is handled by therendermethod inIlluminate/Foundation/Exceptions/Handler.php, and will in turn call the theunauthenticated()method which is defined in yourapp/Exceptions/Handler.php: ...
API 通常使用令牌(token)进行认证并且在请求之间不维护会话(Session)状态。Laravel 官方扩展包 Laravel Passport 让 API 认证变得轻而易举,Passport 基于 Alex Bilbie 维护的 League OAuth2 server,可以在数分钟内为 Laravel 应用提供完整的 OAuth2 服务器实现。
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation. Code of Conduct In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct. Security Vulnerabilities If you dis...
use Laravel\Passport\Passport; class AuthServiceProvider extends ServiceProvider { /** * Register any authentication / authorization services. * * @return void */ public function boot() { // other code Passport::routes(); Passport::tokensExpireIn(now()->addDays(30)); // 这里设置为 30 天...
use Laravel\Passport\Passport; class AuthServiceProvider extends ServiceProvider { /** * Register any authentication / authorization services. * * @return void */ public function boot() { // other code Passport::routes(); Passport::tokensExpireIn(now()->addDays(30)); //这里设置为30天过期...