waglpz/google-sso
Composer 安装命令:
composer require waglpz/google-sso
包简介
Single sign on with Google. Minimal implementation.
README 文档
README
The Google SSO Client Library enables you to work with single sign on via Google API.
Requirements
PHP 8.2 or higher
Installation
composer require waglpz/google-sso:"^1.0"
Authentication with OAuth
- Follow the instructions to Create Web Application Credentials
- Download the JSON credentials in some hidden directory and include this one path in config.
- Set the path to these credentials using config
authConfig. - Set the scopes required for the API you are going to call using config key
scopes - Set your application's redirect URI in config
- Set expected prompt when redirect to google. These can
none,consentorselect_account. - In the script handling the redirect URI, exchange the authorization code for an access token:
Example
$config = include __DIR__ . '/../config/sso.php'; $googleSSO = new \GoogleSSO\GoogleSSO($config); $authorizationCodeUrl = $googleSSO->createAuthUrl(); // Go to the $authorizationCodeUrl and select account you will authenticate against. // these will redirect you to defined/known redirect URI and a PHP script will use the code which sends back from Google. $accountData = $googleSSO->fetchAccountDataUsingAuthorizationCode($_GET['code']); // $accountData contains necessary information if one was founded by google
Code Quality and Testing
To check for coding style violations, run
composer waglpz:code:style:check
To automatically fix (fixable) coding style violations, run
composer waglpz:code:style:fix
To check for static type violations, run
waglpz:code:analyse
To check for regressions, run
composer waglpz:test:norma
To check all violations at once, run
composer waglpz:check:normal
统计信息
- 总下载量: 3.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-25