noriel0010/third-party-sso

PHP库,用于验证和验证来自不同社交平台(如facebook、microsoft、google、linkedin和apple)的3rd party AccessToken/IdToken,并通过提到的社交平台ID进行用户认证


README

Latest Version

安装

通过Composer安装此库。

composer require noriel0010/third-party-sso

示例用法

use Noriel\SSO\Auth\Service\ThirdPartyService;

$service = new ThirdPartyService();

try {
    $apple = $service->apple('apple.identity.token', 'your.app.as.audience')->authenticate();
    $facebook = $service->facebook('facebook.access.token')->authenticate();
    $google = $service->google('google.access.token', 'google_key')->authenticate();
    $linkedin = $service->linkedin('linkedin.access.token')->authenticate();
    $microsoft = $service->microsoft('microsoft.access.token')->authenticate();
} catch (\Throwable $th) {
    echo $th->getMessage();
}

authenticate()方法返回对象数据类型

Apple

对于Apple,这假设您已经从identityToken或从accessToken或从refresh_token中生成。请记住,identityToken仅在10分钟内有效。

使用

测试

要测试Apple,您可以将新生成的identityToken粘贴到test/Apple/AppleTest.php:24中,并将您的audience粘贴到test/Apple/AppleTest.php:25中,然后运行.\vendor\bin\phpunit test/Apple

Facebook

对于Facebook,这假设您已经生成了accessToken

使用

测试

要测试Facebook,您可以将新生成的accessToken粘贴到test/Facebook/FacebookTest.php:24中,然后运行.\vendor\bin\phpunit test/Facebook

Google

对于Google,这假设您已经生成了accessTokenGoogle API密钥

使用

测试

要测试Google,您可以将新生成的accessToken粘贴到test/Google/GoogleTest.php:24中,并将您的key粘贴到test/Google/GoogleTest.php:25中,然后运行.\vendor\bin\phpunit test/Google

LinkedIn

对于LinkedIn,这假设您已经生成了accessToken

使用

测试

要测试Linkedin,您可以将新生成的accessToken粘贴到test/Linkedin/LinkedinTest.php:24中,然后运行.\vendor\bin\phpunit test/Linkedin

Microsoft

对于Microsoft,这假设您已经生成了accessToken

使用

测试

为了测试微软(Microsoft),您可以将您刚刚生成的 accessToken 粘贴到 test/Microsoft/MicrosoftTest.php:24,然后运行 .\vendor\bin\phpunit test/Microsoft