sadiq-bd/google-auth
最新稳定版本:1.1.0
Composer 安装命令:
composer require sadiq-bd/google-auth
包简介
Google Auth lib for PHP
README 文档
README
Google Auth
A simple and efficient Google Authentication Library for PHP.
Table of Contents
Features
- 🔒 Easy integration with Google OAuth2
- 📦 Lightweight & dependency friendly
- 📝 Well-documented and simple API
- ⚡ Fast and secure authentication
- 🛡️ Follows best security practices
Installation
Install via Composer:
composer require sadiq-bd/google-auth
Quick Start
require 'vendor/autoload.php'; use SadiqBd\GoogleAuth\GoogleAuth; $googleAuth = new GoogleAuth( 'YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', 'YOUR_REDIRECT_URI' ); // Redirect to Google OAuth header('Location: ' . $googleAuth->createAuthUrl()); exit();
Usage
1. Configure Google Console
- Go to Google Cloud Console
- Create a new OAuth 2.0 Client ID
- Set your redirect URI
2. Authenticate and Get User Info
// After redirect, handle the callback if (isset($_GET['code'])) { $token = $googleAuth->fetchAccessToken($_GET['code']); $user = $googleAuth->getUserInfo($token['access_token']); // Do something with $user }
Configuration
| Option | Description |
|---|---|
client_id |
Google OAuth2 Client ID |
client_secret |
Google OAuth2 Client Secret |
redirect_uri |
Your App's Redirect URI |
API Reference
| Method | Description |
|---|---|
getAuthUrl() |
Generates the Google OAuth2 authorization URL |
fetchAccessToken() |
Exchanges code for an access token |
getUserInfo() |
Retrieves authenticated user's information |
Contributing
Contributions are welcome! Please open issues or submit pull requests for improvements or bug fixes.
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-02-03