codepeak / oauth2-fortnox
A Fortnox provider for league/oauth2-client
Installs: 1 648
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: >=8.0
- league/oauth2-client: ^2.6
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.3.1
- squizlabs/php_codesniffer: ^2.3 || ^3.0
Suggests
- illuminate/support: Laravel integration
README
This is a package to integrate Fortnox authentication with the OAuth2 client library by The League of Extraordinary Packages.
Installation
composer require codepeak/oauth2-fortnox
Usage
Create instance of the provider
$provider = new \Codepeak\OAuth2\Client\Provider\Fortnox([ 'clientId' => "YOUR_CLIENT_ID", 'clientSecret' => "YOUR_CLIENT_SECRET", 'redirectUri' => "https://your.redirect.uri/full/url/path/here" ]);
Get authorization URL
$authorizationUrl = $provider->getAuthorizationUrl(['scope' => ['companyinformation', 'profile']]);
Get the access token
$token = $provider->getAccessToken("authorization_code", [ 'code' => $_GET['code'] ]);
Refresh access token
$token = $provider->getAccessToken("refresh_token", [ 'refresh_token' => $refreshToken ]);