tomas-kulhanek/oauth2-fakturoid
最新稳定版本:v1.0.0
Composer 安装命令:
composer require tomas-kulhanek/oauth2-fakturoid
包简介
Fakturoid OAuth 2.0 Client Provider for The PHP League OAuth2-Client
README 文档
README
League OAuth2 Client provider for Fakturoid invoicing platform.
Installation
composer require tomas-kulhanek/oauth2-fakturoid
Usage
Authorization Code Flow
use TomasKulhanek\OAuth2\Fakturoid\FakturoidProvider; $provider = new FakturoidProvider([ 'clientId' => 'your-client-id', 'clientSecret' => 'your-client-secret', 'redirectUri' => 'https://your-app.com/callback', ]); // Step 1: Redirect to authorization $authUrl = $provider->getAuthorizationUrl(); $_SESSION['oauth2state'] = $provider->getState(); header('Location: ' . $authUrl); exit; // Step 2: Handle callback if ($_GET['state'] !== $_SESSION['oauth2state']) { exit('Invalid state'); } $token = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'], ]); // Step 3: Get resource owner $owner = $provider->getResourceOwner($token); echo $owner->getId(); echo $owner->getFullName(); echo $owner->getEmail(); echo $owner->getAvatarUrl(); echo $owner->getDefaultAccount();
Client Credentials Flow
$token = $provider->getAccessToken('client_credentials');
Refreshing a Token
$newToken = $provider->getAccessToken('refresh_token', [ 'refresh_token' => $existingToken->getRefreshToken(), ]);
Accessing Accounts
The resource owner provides access to all Fakturoid accounts the user can manage:
$owner = $provider->getResourceOwner($token); foreach ($owner->getAccounts() as $account) { echo $account['slug']; // Account URL identifier echo $account['name']; // Account name echo $account['permission']; // 'owner', 'accountant', etc. echo $account['registration_no'];// Registration number }
Fakturoid OAuth Endpoints
| Endpoint | URL |
|---|---|
| Authorization | https://app.fakturoid.cz/api/v3/oauth |
| Token | https://app.fakturoid.cz/api/v3/oauth/token |
| User Info | https://app.fakturoid.cz/api/v3/user.json |
License
MIT
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-20