OAuth::Lite2::Server::Error(3pm)

OAuth::Lite2::Server::Error3pm

Oauth 2.0 server errors

Usage

    # 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 $_;
        }
    };

Overview

OAuth 2.0 error classes.

See <http://tools.ietf.org/html/draft-ietf-oauth-v2-09>, <http://tools.ietf.org/html/rfc6749>,

Methods

There are following errors

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

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13