logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

OAuth::Lite2::Server::Error - OAuth 2.0 server errors

Author

       Ryo Ito, <ritou.06@gmail.com>

       Lyo Kato, <lyo.kato@gmail.com>

Description

Errors

       OAuth::Lite2::Server::Error::InvalidRequest
       OAuth::Lite2::Server::Error::InvalidClient
       OAuth::Lite2::Server::Error::UnauthorizedClient
       OAuth::Lite2::Server::Error::RedirectURIMismatch
       OAuth::Lite2::Server::Error::AccessDenied
       OAuth::Lite2::Server::Error::UnsupportedResponseType
       OAuth::Lite2::Server::Error::UnsupportedResourceType
       OAuth::Lite2::Server::Error::InvalidGrant
       OAuth::Lite2::Server::Error::UnsupportedGrantType
       OAuth::Lite2::Server::Error::InvalidScope
       OAuth::Lite2::Server::Error::InvalidToken
       OAuth::Lite2::Server::Error::ExpiredTokenLegacy
       OAuth::Lite2::Server::Error::ExpiredToken
       OAuth::Lite2::Server::Error::InsufficientScope
       OAuth::Lite2::Server::Error::InvalidServerState
       OAuth::Lite2::Server::Error::TemporarilyUnavailable
       OAuth::Lite2::Server::Error::ServerError

Methods

       There are following errors

Name

       OAuth::Lite2::Server::Error - OAuth 2.0 server errors

Synopsis

           # At End-User Endpoint

           try {

               if ($something_wrong) {

                   OAuth::Lite2::Server::Error::InvalidRequest->throw(
                       description => q{Something wrong},
                       # state     => q{foo},
                   );
               }

           } catch {

               if ($_->isa("OAuth::Lite2::Server::Error")) {

                   my $uri = URI->new( $client_callback_uri );

                   my %error_params = ( error => $_->type );
                   $error_params{error_description} = $_->description if $_->description;
                   $error_params{state} = $_->state if $_->state;

                   $uri->query_form(%error_params);

                   $your_app->redirect( $uri->as_string );

               } else {

                   # Internal Server Error

               }
           };

           # At token-endpoint

           try {

           } catch {

               if ($_->isa("OAuth::Lite2::Server::Error")) {

                   my %error_params = ( error => $_->type );
                   $error_params{error_description} = $_->description if $_->description;
                   $error_params{scope} = $_->scope if $_->scope;

                   $req->new_response($_->code,
                       [ "Content-Type" => $formatter->type, "Cache-Control" => "no-store" ],
                       [ $formatter->format(\%error_params) ],
                   );

               } else {

                   # rethrow
                   die $_;

               }

           };

See Also