revolution / socialite-wordpress
Socialite for WordPress
Installs: 8 520
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 4
Open Issues: 2
Requires
- php: ^8.0
- ext-json: *
- laravel/socialite: *
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^10.5
This package is auto-updated.
Last update: 2024-12-02 08:46:12 UTC
README
WordPress.com and Self-hosted WordPress.
For Self-hosted WordPress
You must install WP OAuth Server plugin.
https://wordpress.org/plugins/oauth2-provider/
Requirements
- PHP >= 8.0
No version restrictions. It may stop working in future versions.
Installation
composer require revolution/socialite-wordpress
config/services.php
'wordpress' => [ // Endpoint for WordPress.com // 'host' => env('WORDPRESS_HOST', 'https://public-api.wordpress.com/oauth2'), // 'api_me' => env('WORDPRESS_API_ME', 'https://public-api.wordpress.com/rest/v1.1/me'), // Endpoint for Self-hosted WordPress 'host' => env('WORDPRESS_HOST'), 'api_me' => env('WORDPRESS_API_ME', env('WORDPRESS_HOST') . '/me/'), 'client_id' => env('WORDPRESS_CLIENT_ID'), 'client_secret' => env('WORDPRESS_CLIENT_SECRET'), 'redirect' => env('WORDPRESS_REDIRECT'), ],
.env
WORDPRESS_HOST=https://example.com/oauth
#WORDPRESS_API_ME=
WORDPRESS_CLIENT_ID=
WORDPRESS_CLIENT_SECRET=
WORDPRESS_REDIRECT=
Usage
routes/web.php
Route::get('login', [SocialiteController::class, 'login']); Route::get('callback', [SocialiteController::class, 'callback']);
SocialiteController
namespace App\Http\Controllers; use Illuminate\Http\Request; use Socialite; class SocialiteController extends Controller { public function login() { return Socialite::driver('wordpress')->redirect(); } public function callback() { $user = Socialite::driver('wordpress')->user(); dd($user); } }
Demo
https://github.com/kawax/socialite-project
LICENCE
MIT
Copyright kawax