2017 © Pedro Peláez
 

yii2-extension yii2-simple-auth-yii-authenticator

Yii 2 extension that provides helper for authenticate Request from yii2-httpclient package.

image

rob006/yii2-simple-auth-yii-authenticator

Yii 2 extension that provides helper for authenticate Request from yii2-httpclient package.

  • Saturday, October 7, 2017
  • by rob006
  • Repository
  • 1 Watchers
  • 0 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 3 % Grown

The README.md

Helper for authenticate Request from yii2-httpclient package

Yii 2 extension that provides helper for authenticate Request from yii2-httpclient package., (*1)

This is a simple helper for yii2-simple-auth which simplify authenticating Request object from official Yii 2 httpclient extension. Read yii2-simple-auth README to get more details about authentication process and configuration., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require rob006/yii2-simple-auth-yii-authenticator

or add, (*5)

"rob006/yii2-simple-auth-yii-authenticator": "^1.0"

to the require section of your composer.json file., (*6)

Usage

You can simply authenticate Request object from official Yii 2 httpclient by using YiiAuthenticator helper:, (*7)

use yii\httpclient\Client;
use rob006\simpleauth\YiiAuthenticator as Authenticator;

$client = new Client();
$request = $client->createRequest()
    ->setUrl('http://api.example.com/user/list/')
    ->setData(['ids' => '1,2,3,4']);
$request = Authenticator::authenticate($request);
$response = $request->send();

By default Authenticator sends authentication token in the header of the request. Alternatively you can send it in GET or POST param of request. Be careful when you using POST method because this will set request method as POST and all data set by \yii\httpclient\Request::setData() will be sent as POST data and will not be included in the URL., (*8)

Authentication by GET param with custom secret key:, (*9)

use yii\httpclient\Client;
use rob006\simpleauth\YiiAuthenticator as Authenticator;

$client = new Client();
$request = $client->createRequest()
    ->setUrl('http://api.example.com/user/list/')
    ->setData(['ids' => '1,2,3,4']);
$request = Authenticator::authenticate($request, Authenticator::METHOD_GET, 'mycustomsecretkey');
$response = $request->send();

Authentication by POST param:, (*10)

use yii\httpclient\Client;
use rob006\simpleauth\YiiAuthenticator as Authenticator;

$client = new Client();
$request = $client->createRequest()
    ->setUrl('http://api.example.com/user/list/?ids=1,2,3,4');
$request = Authenticator::authenticate($request, Authenticator::METHOD_POST);
$response = $request->send();

The Versions

07/10 2017

dev-master

9999999-dev https://github.com/rob006-software/yii2-simple-auth-yii-authenticator

Yii 2 extension that provides helper for authenticate Request from yii2-httpclient package.

  Sources   Download

MIT

The Requires

 

authentication extension auth yii2 authenticator

06/04 2017

1.0.1

1.0.1.0

Yii 2 extension that provides helper for authenticate Request from yii2-httpclient package.

  Sources   Download

MIT

The Requires

 

authentication extension auth yii2 authenticator

04/09 2016

1.0.0

1.0.0.0

Yii 2 extension that provides helper for authenticate Request from yii2-httpclient package.

  Sources   Download

MIT

The Requires

 

authentication extension auth yii2 authenticator