SERVER/LARAVEL & PHP

The resource owner or authorization server denied the request

나나나나나나나ㅏ나난ㄴ나ㅏ나나 2021. 8. 17. 18:49
728x90

오류내용

 

production.ERROR: The resource owner or authorization server denied the request. {"exception":"[object] (League\\OAuth2\\Server\\Exception\\OAuthServerException(code: 9): The resource owner or authorization server denied the request. at vendor/league/oauth2-server/src/Exception/OAuthServerException.php:243)


 

해결

 

app/Exceptions/Handler.php 에 두가지 추가!

 

protected $dontReport = [
  //
  \League\OAuth2\Server\Exception\OAuthServerException::class
];
public function report(Throwable $e)
{

  if ($e instanceof \League\OAuth2\Server\Exception\OAuthServerException && $e->getCode() == 9) {
	  return ;
  }

	parent::report($e); // TODO: Change the autogenerated stub
}

 

다른 사이트 보면 report에 Exception  을 넣어서 수정하라고 한 경우가 많은데 버전 8에서는 Throwable로 기본이 변경되었다.

 


전체 코드

 

<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that are not reported.
     *
     * @var array
     */
    protected $dontReport = [
        //
        \League\OAuth2\Server\Exception\OAuthServerException::class
    ];

    /**
     * A list of the inputs that are never flashed for validation exceptions.
     *
     * @var array
     */
    protected $dontFlash = [
        'current_password',
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     *
     * @return void
     */
    public function register()
    {
        $this->reportable(function (Throwable $e) {
            //


        });
    }

    public function report(Throwable $e)
    {

        if ($e instanceof \League\OAuth2\Server\Exception\OAuthServerException && $e->getCode() == 9) {
            return ;
        }

        parent::report($e); // TODO: Change the autogenerated stub
    }


}
728x90