laravel 如何将 passport的token_id 转换为 access_token

  1. 通过passport创建令牌的事件AccessTokenCreated得到生成的token,如何在该事件中根据生成的token_id转换成相应的access_token


呼如林
浏览 1337回答 1
1回答

神不在的星期二

翻找源码,按照他的格式重新写了一下,不是特别优雅<?phpnamespace&nbsp;App\Listeners;use&nbsp;Carbon\Carbon;use&nbsp;Illuminate\Support\Facades\Config;use&nbsp;Illuminate\Support\Facades\DB;use&nbsp;Illuminate\Support\Facades\Redis;use&nbsp;Laravel\Passport\Bridge\AccessToken;use&nbsp;Laravel\Passport\Bridge\AccessTokenRepository;use&nbsp;Laravel\Passport\Bridge\AuthCodeRepository;use&nbsp;Laravel\Passport\Bridge\ClientRepository;use&nbsp;Laravel\Passport\Bridge\Scope;use&nbsp;Laravel\Passport\Events\AccessTokenCreated;use&nbsp;Illuminate\Queue\InteractsWithQueue;use&nbsp;Illuminate\Contracts\Queue\ShouldQueue;use&nbsp;Laravel\Passport\Passport;use&nbsp;Laravel\Passport\Token;use&nbsp;League\OAuth2\Server\AuthorizationServer;use&nbsp;League\OAuth2\Server\CryptKey;use&nbsp;League\OAuth2\Server\Entities\ScopeEntityInterface;use&nbsp;League\OAuth2\Server\Entities\Traits\AccessTokenTrait;use&nbsp;League\OAuth2\Server\Entities\Traits\EntityTrait;use&nbsp;League\OAuth2\Server\Entities\Traits\TokenEntityTrait;use&nbsp;League\OAuth2\Server\Exception\OAuthServerException;
打开App,查看更多内容
随时随地看视频慕课网APP