PHPackages                             iphpjs/socialite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. iphpjs/socialite

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

iphpjs/socialite
================

A collection of OAuth 2 packages.

3.2.1(5y ago)110MITPHPPHP &gt;=7.4

Since Dec 9Pushed 5y agoCompare

[ Source](https://github.com/iphpjs/socialite)[ Packagist](https://packagist.org/packages/iphpjs/socialite)[ Patreon](https://www.patreon.com/overtrue)[ RSS](/packages/iphpjs-socialite/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (5)Versions (70)Used By (0)

 Socialite
==========

[](#-socialite)

[![Latest Stable Version](https://camo.githubusercontent.com/c4749ba8861fa6a83a1292608571c847b1819806543a90d839a4e0e0508f0722/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f736f6369616c6974652f762f737461626c652e737667)](https://packagist.org/packages/overtrue/socialite)[![Latest Unstable Version](https://camo.githubusercontent.com/9576aa8da9eaf92f975f11c1f95803dd62483a7d912aad22feb3dc7be12a5277/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f736f6369616c6974652f762f756e737461626c652e737667)](https://packagist.org/packages/overtrue/socialite)[![Build Status](https://camo.githubusercontent.com/84824a0b71246e2fd9e22abc3f547f249c208fb5ac73f65d3c0a2c258ba17f79/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f766572747275652f736f6369616c6974652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/overtrue/socialite/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8875667fdd3207182eae14a679413579def05bbf58700fbbbc3191cfaa7fd782/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f766572747275652f736f6369616c6974652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/overtrue/socialite/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/40c66609e54ea696e7f8e3dde8c816f48a8f1b64a4a41f1bb764140008f4f60c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f766572747275652f736f6369616c6974652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/overtrue/socialite/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/5f91220582b557781a69c0d377967c9cfd094da1bbd7f05c3932984cf59335ac/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f736f6369616c6974652f646f776e6c6f616473)](https://packagist.org/packages/overtrue/socialite)[![License](https://camo.githubusercontent.com/e7a731ae7b59dc7b6d4aca5064a4d703aa8908e4d79c8ee0409f68ca989bee84/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f736f6369616c6974652f6c6963656e7365)](https://packagist.org/packages/overtrue/socialite)

Socialite is an [OAuth2](https://oauth.net/2/) Authentication tool. It is inspired by [laravel/socialite](https://github.com/laravel/socialite), You can easily use it in any PHP project. [中文文档](/README_CN.md)

This tool now supports platforms such as Facebook, GitHub, Google, LinkedIn, Outlook, QQ, Tapd, Alipay, Taobao, Baidu, DingTalk, Weibo, WeChat, Douyin, Feishu, Douban, WeWork, Tencent Cloud.

- [Requirement](#requirement)
- [Installation](#installation)
- [Usage](#usage)
    - [Configuration](#configuration)
        - [Custom app name](#custom-app-name)
        - [Extends custom provider](#extends-custom-provider)
    - [Platform](#platform)
        - [Alipay](#alipay)
        - [DingTalk](#dingtalk)
        - [Douyin](#douyin)
        - [Baidu](#baidu)
        - [Feishu](#feishu)
        - [Taobao](#taobao)
        - [WeChat](#wechat)
    - [Some Skill](#some-skill)
        - [Scopes](#scopes)
        - [Redirect URL](#redirect-url)
        - [State](#state)
        - [Redirect with `state` parameter](#redirect-with-state-parameter)
        - [Validate the callback `state`](#validate-the-callback-state)
        - [Additional parameters](#additional-parameters)
    - [User interface](#user-interface)
        - [Standard user api:](#standard-user-api)
        - [Get raw response from OAuth API](#get-raw-response-from-oauth-api)
        - [Get the token response when you use userFromCode()](#get-the-token-response-when-you-use-userfromcode)
        - [Get user with access token](#get-user-with-access-token)
- [Enjoy it! ❤️](#enjoy-it-heart)
- [Reference](#reference)
- [PHP 扩展包开发](#php-%E6%89%A9%E5%B1%95%E5%8C%85%E5%BC%80%E5%8F%91)
- [License](#license)

Requirement
===========

[](#requirement)

```
PHP >= 7.4

```

Installation
============

[](#installation)

```
$ composer require "overtrue/socialite" -vvv
```

Usage
=====

[](#usage)

Users just need to create the corresponding configuration variables, then create the authentication application for each platform through the tool, and easily obtain the access\_token and user information for that platform. The implementation logic of the tool is referred to OAuth2 documents of major platforms for details.

The tool is used in the following steps:

1. Configurate platform config
2. Use this tool to create a platform application
3. Let the user redirect to platform authentication
4. The server receives a Code callback from the platform, and uses the Code to exchange the user information on the platform (including access\_token).

Packages created for Laravel users are easier to integrate: [overtrue/laravel-socialite](https://github.com/overtrue/laravel-socialite)

`authorize.php`:

```
