PHPackages                             tourze/sina-weibo-oauth2-bundle - 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. tourze/sina-weibo-oauth2-bundle

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

tourze/sina-weibo-oauth2-bundle
===============================

Sina Weibo

0.0.1(6mo ago)00MITPHPCI passing

Since Dec 19Pushed 6mo agoCompare

[ Source](https://github.com/tourze/sina-weibo-oauth2-bundle)[ Packagist](https://packagist.org/packages/tourze/sina-weibo-oauth2-bundle)[ RSS](/packages/tourze-sina-weibo-oauth2-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (41)Versions (2)Used By (0)

Sina Weibo OAuth2 Bundle
========================

[](#sina-weibo-oauth2-bundle)

[![Latest Version](https://camo.githubusercontent.com/adcfbf7ee0c98d125519294a8dcc2158ab02fd2e68de6120da449ba53c197742/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f73696e612d776569626f2d6f61757468322d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/sina-weibo-oauth2-bundle)[![PHP Version](https://camo.githubusercontent.com/c3d372b55ac2d4fcf386a178e11d9788310097b35f3893cf3daae574b6b4cd3e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75652e7376673f7374796c653d666c61742d737175617265)](https://php.net/)[![Symfony Version](https://camo.githubusercontent.com/cec82f7b46eaf53738cc8df5444106649bab3463e0fd5ff6611501e5eaaa97cb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253545372e332d707572706c652e7376673f7374796c653d666c61742d737175617265)](https://symfony.com/)[![License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://github.com/tourze/php-monorepo/workflows/CI/badge.svg)](https://github.com/tourze/php-monorepo/actions)[![Coverage](https://camo.githubusercontent.com/b3545ae1bcdb4ea486f71f87b43001e82dd21933bc8035d44601706c851265da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e737667)](https://github.com/tourze/php-monorepo)[![Total Downloads](https://camo.githubusercontent.com/f3ee63fed2fcb78abd87b598432dd6f264df7b1008ad27174325f19b4354327d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f73696e612d776569626f2d6f61757468322d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/sina-weibo-oauth2-bundle)

[English](README.md) | [中文](README.zh-CN.md)

A comprehensive Symfony bundle that provides seamless integration with Sina Weibo OAuth2 authentication, including user management, token handling, and administrative tools.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Advanced Usage](#advanced-usage)
- [Console Commands](#console-commands)
- [System Requirements](#system-requirements)
- [Security](#security)
- [License](#license)

Features
--------

[](#features)

- ✅ **Complete OAuth2 Flow**: Full implementation of Sina Weibo OAuth2 authentication
- 🏗️ **Doctrine Integration**: Pre-built entities for configurations, users, and states
- 🎛️ **Management Commands**: Console commands for easy configuration and maintenance
- 🧹 **Auto Cleanup**: Automatic cleanup of expired tokens and authentication states
- 🚀 **Ready-to-use Controllers**: Built-in login and callback controllers
- 📊 **Repository Pattern**: Clean data access layer with optimized queries
- 🔒 **Security First**: CSRF protection via state validation and secure token handling
- 🧪 **100% Test Coverage**: Comprehensive unit and integration tests
- 📚 **Bilingual Documentation**: Complete documentation in English and Chinese

Installation
------------

[](#installation)

```
composer require tourze/sina-weibo-oauth2-bundle
```

Quick Start
-----------

[](#quick-start)

### 1. Configure OAuth2 Application

[](#1-configure-oauth2-application)

Use the configuration command to set up your Sina Weibo OAuth2 application:

```
php bin/console sina-weibo-oauth2:config create --app-id=YOUR_APP_ID --app-secret=YOUR_APP_SECRET --scope=email
```

### 2. Basic Usage

[](#2-basic-usage)

The bundle provides two pre-built controllers for OAuth2 flow:

- **Login URL**: `/sina-weibo-oauth2/login` - Redirects to Sina Weibo for authentication
- **Callback URL**: `/sina-weibo-oauth2/callback` - Handles the OAuth2 callback

#### Using Built-in Controllers

[](#using-built-in-controllers)

Simply redirect users to the login URL:

```
