Skip to content

[Social login]Socialite is an OAuth1/OAuth2 Authentication tool.

License

Notifications You must be signed in to change notification settings

socialite-manager/socialite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Socialite

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()