PHP code example of codepeak / oauth2-fortnox

1. Go to this page and download the library: Download codepeak/oauth2-fortnox library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codepeak / oauth2-fortnox example snippets


$provider = new \Codepeak\OAuth2\Client\Provider\Fortnox([
    'clientId' => "YOUR_CLIENT_ID",
    'clientSecret' => "YOUR_CLIENT_SECRET",
    'redirectUri' => "https://your.redirect.uri/full/url/path/here"
]);

$authorizationUrl = $provider->getAuthorizationUrl(['scope' => ['companyinformation', 'profile']]);

$token = $provider->getAccessToken("authorization_code", [
    'code' => $_GET['code']
]);

$token = $provider->getAccessToken("refresh_token", [
    'refresh_token' => $refreshToken
]);