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 C<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 C<_token_request_p> method that returns a C<Mojo::Promise>
containing C<token> and C<token_type> in a HashRef.

See L<PayProp::API::Public::Client::Authorization::ClientCredentials> implementation using storage and request pattern, and
L<PayProp::API::Public::Client::Authorization::APIKey> for returning token information directly.

ATTRIBUTES

C<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 E<lt>yangak@cpan.orgE<gt>

Valters Skrupskis E<lt>malishew@cpan.orgE<gt>

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:

L<https://github.com/Humanstate/api-client-public-module>