我正在嘗試使用 Laravel Passport 和我的 SPA 應用程式實作授權代碼授予。我偶然發現了以下問題:
據我所知,OAuth 中的范圍是可選的,我不必在請求代碼時請求一個。即使在
有誰知道這里發生了什么?
問候, 羅伯
uj5u.com熱心網友回復:
在您的 URL 中有scope=''&而不是scope=&.
嘗試使用http_build_query()as per docs構建查詢引數。
$query = http_build_query([
'client_id' => 'client-id',
'redirect_uri' => 'http://third-party-app.com/callback',
'response_type' => 'code',
'scope' => '',
'state' => $state,
'code_challenge' => $codeChallenge,
'code_challenge_method' => 'S256',
]);
其次,你的code_challenge結尾是=.
所以你可能應該:
- 去掉
=末尾的符號this.challenge - 替換為
_-this.challenge - 替換為
/__this.challenge
PHP 示例
$encoded = base64_encode(hash('sha256', $code_verifier, true));
$codeChallenge = strtr(rtrim($encoded, '='), ' /', '-_');
uj5u.com熱心網友回復:
據我所知,您可以將范圍硬編碼為“*”,這應該可以作業,我也是這樣做的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/444747.html
