web-dev-qa-db-ja.com

Laravel Passport-サポートされていない付与タイプ

ドキュメントごとにLaravel Passportをインストールし、必要なコードのすべての領域を変更しました。

ユーザーがサイトのユーザー名とパスワードでログインするときにAPIトークンを取得できるように、パスワード付与トークンの設定に取り組んでいます。 grant_typeに関しては問題に直面しています。何らかの理由でLaravelは無効な付与タイプについて不満を言っています。

{
  "error": "unsupported_grant_type",
  "message": "The authorization grant type is not supported by the authorization server.",
  "hint": "Check the `grant_type` parameter"
}

これらは私が/oauth/tokenに投稿しているフィールドです

client_id = 4
client_secret = SMiYE7XqDNtXKQnmkYmFnXxfAaV83vRhnJ9zwCtZ
username = [email protected]
password = **************
grant_type = password
scope = *

php artisan passport:installを実行し、php artisan passport:client --passwordを実行しようとしました

両方のコマンドが機能し、両方がクライアントとシークレットを作成しましたが、grant_typeに関するエラーを乗り越えることはできません。

パスワードグラントトークンが機能するように、これを解決するために検討すべきことについての提案はありますか?

16
Joseph Crawford

パラメータをフォームデータとして送信する必要があり、ヘッダーではなく、私がやっているように見えます... Rookie Mistake!

29
Joseph Crawford

Postmanを使用していますが、すべてのパラメーターをParamsに入れています。 Postmanは次の応答を表示します

{
    "error": "unsupported_grant_type",
    "message": "The authorization grant type is not supported by the authorization server.",
    "hint": "Check the `grant_type` parameter"
}

ここで、すべてのパラメーターをBodyに入れてから、[送信]ボタンを押します。うまく機能しています。

7
Muhammad Hashim

初期URL

https://restfulapi.test/oauth/authorize?client_id=3&redirect_url=http://restfulapi.test?response_type=code

解決

https://restfulapi.test/oauth/authorize?client_id=3&redirect_url=http://restfulapi.test&response_type=code

Response_typeの前の疑問符を&に置き換える必要がありました

0
MT_Shikomba