NAME
PayProp::API::Public::Client::Authorization::Base - Base module for authorization modules.
SYNOPSIS
{
package PayProp::API::Public::Client::Authorization::Custom;
use Mouse;
extends qw/ PayProp::API::Public::Client::Authorization::Base /;
...;
__PACKAGE__->meta->make_immutable;
}
my $CustomAuthorization = PayProp::API::Public::Client::Authorization::Custom->new;
DESCRIPTION
*DO NOT INSTANTIATE THIS MODULE DIRECTLY*
Base authorization module for alternative implementations. This module expects for PayProp::API::Public::Client::Authorization::*
modules to define their own implementation on how the token should be returned. The base module will handle retrieving token either directly or from a defined storage solution.
The only requirement this module has is for extending modules to override _token_request_p
method that returns a Mojo::Promise
containing token
and token_type
in a HashRef.
See PayProp::API::Public::Client::Authorization::ClientCredentials implementation using storage and request pattern, and PayProp::API::Public::Client::Authorization::APIKey for returning token information directly.
ATTRIBUTES
PayProp::API::Public::Client::Authorization::Base
implements the following attributes.
is_token_from_storage
$CustomAuthorization->is_token_from_storage(0);
my $is_token_from_storage = $CustomAuthorization->is_token_from_storage;
METHODS
token_request_p
### APIkey ###
$APIKeyAuthorization
->_token_request_p
->then( sub {
my ( $token_info ) = @_;
cmp_deeply
$token_info,
{
token => 'AgencyAPIKey',
token_type => 'APIkey',
}
} )
->wait
;
### OAuth v2.0 client access token ###
$ClientCredentials
->_token_request_p
->catch( sub {
my ( $Exception ) = @_;
...;
} )
->wait
;
AUTHOR
Yanga Kandeni <yangak@cpan.org>
Valters Skrupskis <malishew@cpan.org>
COPYRIGHT
Copyright 2023- PayProp
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
If you would like to contribute documentation or file a bug report then please raise an issue / pull request: