2017 © Pedro Peláez
 

library jwt-api-client-php

API client prepared to consume API using JWT for PHP

image

bernardosilva/jwt-api-client-php

API client prepared to consume API using JWT for PHP

  • Monday, January 15, 2018
  • by BernardoSilva
  • Repository
  • 1 Watchers
  • 0 Stars
  • 479 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 151 % Grown

The README.md

JWT API Client for PHP

Jason Web Token API client is a library to facilitate consuming API's that require JWT token as authentication., (*1)

Latest Stable Version Total Downloads Build Status License, (*2)

How to Install

$ composer require bernardosilva/jwt-api-client-php

How to use

use BernardoSilva\JWTAPIClient\APIClient;
use BernardoSilva\JWTAPIClient\AccessTokenCredentials;

$username = 'your-username';
$password = 'your-password';
$baseURI = 'api.your-domain.pt';


$client = new APIClient($baseURI);
$options = [
    'verify' => false, // might need this if API uses self signed certificate
    'form_params' => [
        'key' => $username,
        'password' => $password
    ]
];

// authenticate on API to get token
$response = $client->post('/api/v1/auth/login', $options);
$loginResponseDecoded = json_decode($response->getBody()->getContents(), true);

$credentials = new AccessTokenCredentials($loginResponseDecoded['access_token']);
$client->setCredentials($credentials);

// e.g. Request types
$client->get();
$client->delete();
$client->patch();
$client->post();
$client->put();

Example of how to get access token without requesting the API:, (*3)

// When using internally with other services can generate accessToken directly
$accessToken = $JWTManager->create($user);
$credentials = new AccessTokenCredentials($accessToken);

How to contribute

  • Fork project
  • Clone it to your machine
  • Install dependencies using composer install
  • Open a Pull Request

How to test

$ ./vendor/bin/phpunit

Created by

License

The source code is licensed under GPL v3. License is available here., (*4)

The Versions

15/01 2018

dev-master

9999999-dev

API client prepared to consume API using JWT for PHP

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Bernardo Silva

15/01 2018

0.0.3

0.0.3.0

API client prepared to consume API using JWT for PHP

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Bernardo Silva

15/01 2018

dev-allow-not-check-ssl

dev-allow-not-check-ssl

API client prepared to consume API using JWT for PHP

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Bernardo Silva

05/01 2018

0.0.2

0.0.2.0

API client prepared to consume API using JWT for PHP

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Bernardo Silva

05/01 2018

dev-add-php55

dev-add-php55

API client prepared to consume API using JWT for PHP

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Bernardo Silva

05/01 2018

0.0.1

0.0.1.0

API client prepared to consume API using JWT for PHP

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Bernardo Silva

05/01 2018

dev-remove-auto-login

dev-remove-auto-login

API client prepared to consume API using JWT for PHP

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Bernardo Silva

05/01 2018

dev-make-it-compatible-with-php56

dev-make-it-compatible-with-php56

API client prepared to consume API using JWT for PHP

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Bernardo Silva