2017 © Pedro Peláez
 

library oauth2

Oauth2 consumer

image

psx/oauth2

Oauth2 consumer

  • Wednesday, February 14, 2018
  • by k42b3
  • Repository
  • 1 Watchers
  • 0 Stars
  • 16,470 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 12 % Grown

The README.md

OAuth2

About

This package provides an OAuth2 client implementation and it provides also common DTOs and exceptions to build an OAuth2 server implementation, (*1)

Usage

Authorization code

<?php

// at first for the authorization code flow you need to redirect your user to the OAuth2 server
AuthorizationCode::redirect('[auth_url]', '[client_id]', '[redirect_url]');

// if the customer returns you can obtain an access token
$client = new \PSX\Http\Client\Client();
$code = new \PSX\OAuth2\Authorization\AuthorizationCode($client, new Url('[token_url]'));
$code->setClientPassword('[client_id]', '[client_secret]');

$accessToken = $code->getAccessToken('[redirect_url]');

// if we have an access token we can request the api using the access token
$header = [
    'Authorization' => TokenAbstract::factory($accessToken)->getHeader()
];

$request  = new GetRequest('[api_url]', $header);
$response = $client->request($request);

if ($response->getStatusCode() == 200) {
    // request worked
}

Client credentials

<?php

$client = new \PSX\Http\Client\Client();
$code = new \PSX\OAuth2\Authorization\ClientCredentials($client, new Url('[token_url]'));
$code->setClientPassword('[client_id]', '[client_secret]');

$accessToken = $code->getAccessToken();

// work with the access token

The Versions

14/02 2018

dev-master

9999999-dev http://phpsx.org

Oauth2 consumer

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

oauth

14/02 2018

v2.1.0

2.1.0.0 http://phpsx.org

Oauth2 consumer

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

oauth

17/11 2017

v2.0.1

2.0.1.0 http://phpsx.org

Oauth2 consumer

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

oauth

17/12 2016

v2.0.0

2.0.0.0 http://phpsx.org

Oauth2 consumer

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

oauth

08/05 2016

v1.0.0

1.0.0.0 http://phpsx.org

Oauth2 consumer

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

oauth

03/04 2016

v0.1.1

0.1.1.0 http://phpsx.org

Oauth2 consumer and provider

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

oauth

02/04 2016

v0.1.0

0.1.0.0 http://phpsx.org

Oauth2 consumer and provider

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

oauth