承接 bernardosilva/jwt-api-client-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bernardosilva/jwt-api-client-php

最新稳定版本:0.0.3

Composer 安装命令:

composer require bernardosilva/jwt-api-client-php

包简介

API client prepared to consume API using JWT for PHP

README 文档

README

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

Latest Stable Version Total Downloads Build Status License

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:

// 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.

统计信息

  • 总下载量: 17.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-01-04