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

    }

};

DESCRIPTION

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

AUTHOR

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

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

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Lyo Kato

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.