Download the PHP package germania-kg/authapi-client without Composer

On this page you can find all versions of the php package germania-kg/authapi-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package authapi-client


AuthApi Client

Service-side PHP client for retrieving an Auth token from Germania's Authentication API (AuthApi).

Installation

Interfaces and abstracts

AuthApiInterface

The AuthApiInterface provides three public methods:

AuthApiAbstract

Abstract class AuthApiAbstract implements AuthApiInterface, so you will have to bring the abstract methods to life. They use Psr\Log\LoggerAwareTrait and the LoglevelTrait that comes with this package. So with all instances extending from AuthApiAbstract, you can:


Implementations

Using Guzzle

The GuzzleAuthApi client extends AuthApiAbstract and implements AuthApiInterface. It uses the GuzzleHttp Client to authenticate at Germania's AuthApi. The Guzzle client needs to be configured with the AuthAPI's base_uri.

Set Guzzle Client

Using PSR-18 HTTP client

Class HttpClientAuthApi extends abstract AuthApiDecorator and thus also implements AuthApiInterface.

The constructor requires the AuthApi base URL and a PSR-18 client instance. An optional PSR-3 Logger may be passed as third parameter.

Set base URL

Set PSR-18 HTTP client

Set PSR-17 Request and Stream factory

PSR-6 Cache support

Class CacheAuthApiDecorator is a PSR-6 Cache decorator for any AuthApiInterface instance. It extends abstract AuthApiDecorator and thus also implements AuthApiInterface.

The constructor requires AuthApiInterface instance and a PSR-6 CacheItemPool. An optional PSR-3 Logger may be passed as third parameter.

Set PSR-6 CacheItemPool


Usage Example

This usage example combines the above AuthApi clients.

The AuthToken's life time is usually quite short; to obtain one with longer TTL (i.e. refresh after login), pass a third boolean parameter to the getToken method. The new TTL is derived from the token lifetime.

Exception handling

Any exception thrown by the AuthApi client implements AuthApiExceptionInterface. So catching \Germania\AuthApiClient\Exceptions\AuthApiExceptionInterface usually will be plenty.

Any request-related exception thrown by the Guzzle client will be wrapped up in a AuthApiRequestException. This exception class extends \RuntimeException and implements AuthApiExceptionInterface.

When there's something wrong with the retrieved AuthApi response, an AuthApiResponseException will be thrown. This exception class extends \UnexpectedValueException and implements AuthApiExceptionInterface.

The AuthToken

The AuthToken and AuthTokenInterface rely on Germania's germania-kg/token package: https://packagist.org/packages/germania-kg/token

Interface AuthTokenInterface

The Germania\AuthApiClient\AuthTokenInterface extends Germania\Token\TokenInterface and thus provides these methods inherited from AuthTokenInterface:

Class AuthToken

The Germania\AuthApiClient\AuthToken implements the AuthTokenInterface. It is an extension from Germania\Token\Token.

Create authorized requests: PSR-17 Requestfactory

Once you have your AuthToken, you'll want to authorize at an API. In order to create an authorized PSR-7 Request, you can use class AuthTokenRequestFactory which wraps another “inner” PSR-17 RequestFactory.

The constructor requires an AuthToken instance or equivalent string; it optionally accepts any PSR-17 instance; per default Nyholm's PSR-17 RequestFactory will be used.

Testing

Copy phpunit.xml.dist to phpunit.xml and fill in your credentials in the <php> section.


All versions of authapi-client with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
guzzlehttp/guzzle Version ^6.3|^7.0
psr/log Version ^1.1
psr/cache Version ^1.0|^2.0|^3.0
symfony/polyfill-php73 Version ^1.11
germania-kg/jsondecoder Version ^1.0
germania-kg/token Version ^1.0
nyholm/psr7 Version ^1.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package germania-kg/authapi-client contains the following files

Loading the files please wait ....