我遇到了一個問題,我需要根據客戶端ID更改由oauth2服務器使用的配置變量。這是配置:配置變量的變化不是持久化5.2
'grant_types' => [
'password' => [
'class' => '\League\OAuth2\Server\Grant\PasswordGrant',
'callback' => '\App\Api\OAuth2\[email protected]',
'access_token_ttl' => 3600
],
]
然後我才發出帶有Authorizer::issueAccessToken();
令牌我設置的配置變量:config(['oauth2.grant_types.password.access_token_ttl' => 86400]);
,如果我再運行dd(config('oauth2'));
我得到:
'grant_types' => array:1 [
'password' => array:3 [
'class' => '\League\OAuth2\Server\Grant\PasswordGrant',
'callback' => '\App\Api\OAuth2\[email protected]',
'access_token_ttl' => 86400
],
]
但是,如果我讓代碼運行,發出令牌迴應仍是:
{
"access_token": "HOoODcDzXilakd5TtOv4qqBSBUwEqqWhIL36ALdM",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "6mfyizKlRGC55x6ZY8ROx24UcVeWfljikNZv6ME7",
"allowed_scopes": [
"*"
],
"user_is_activated": true
}
如果我硬編碼值'access_token_ttl' => 86400
我得到期望的結果:
{
"access_token": "HOoODcDzXilakd5TtOv4qqBSBUwEqqWhIL36ALdM",
"token_type": "Bearer",
"expires_in": 86400,
"refresh_token": "6mfyizKlRGC55x6ZY8ROx24UcVeWfljikNZv6ME7",
"allowed_scopes": [
"*"
],
"user_is_activated": true
}
問題是,access_token_ttl
需要基於客戶端ID動態。我無法更改供應商庫,因爲這會在未來的更新中破壞。有人知道在運行時在應用程序範圍內更改配置變量的方法,該方法仍然存在於不同的方法中嗎?
如果這是問題,我會注意到它,因爲那樣當硬編碼access_token_ttl的缺省值時它不會改變響應的值,但它確實不是緩存問題。 –