OAuth 1 & OAuth 2 libraries.

v1.0.1 2018-06-09 14:31 UTC

README

Build Status MIT License

Introduction

This is inspired by laravel/socialite, you can easily use it without Laravel.

It possible to use it with various frameworks and middleware.

It is compatible with laravel/socialite.
You can check the Document of laravel.

Core Providers

  • twitter
  • github
  • google
  • facebook
  • bitbucket
  • linkedin

other Providers

Requirement

PHP >= 7.0

Installation

composer require socialite-manager/socialite

Basic Usage

$config = [
    'client_id' => 'xxx',
    'client_secret' => 'xxx',
    'redirect' => 'http://example.com/callback.php',
];

oath.php

use Socialite\Socialite;

Socialite::driver('twitter', $config)->redirect();

callback.php

use Socialite\Socialite;

$user = Socialite::driver('twitter', $config)->user();

$user->getAvatar();
$user->getEmail();
$user->getId();
$user->getNickname();
$user->getName();

Advanced Usage

Sosialite have options for use with framework and middleware

Set Request

Interface: \Psr\Http\Message\ServerRequestInterface

Socialite::driver('twitter', $config)
    ->setRequest($this->request);

Set Session

need one of the following read/write interfaces.

write
$session->put()
$session->set()
$session->write()
read
$session->get()
$session->read()
Socialite::driver('twitter', $config)
    ->setSession($this->request->getSession());

Redirect psr7 response

Psr\Http\Message\ResponseInterface will be returned

Socialite::driver('twitter', $config)->psr7Redirect()