PHP-OAuth2
PHP-OAuth2 copied to clipboard
Custom Grant Type not Found
I'm attempting to use your library in order to generate an oAuth access token, but I'm experiencing some issues. I got the error:
OAuth2\InvalidArgumentException: Unknown grant type 'my_custom_grant_type' in /Applications/AMPPS/www/whmcs/modules/addons/addonmodule/Client.php:219 Stack trace: #0 /Applications/AMPPS/www/whmcs/modules/addons/addonmodule/addonmodule.php(209): OAuth2\Client->getAccessToken('https://api.san...', 'my_custom_grant...', Array) #1 /Applications/AMPPS/www/whmcs/admin/addonmodules.php(0): addonmodule_sidebar(Array) #2 {main}
When I tried to run: ` $CLIENT_ID = $vars['id']; $CLIENT_SECRET = $vars['secret'];
$REDIRECT_URI = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"]; $AUTHORIZATION_ENDPOINT = 'https://api.sandbox.freeagent.com/v2/approve_app'; $TOKEN_ENDPOINT = 'https://api.sandbox.freeagent.com/v2/token_endpoint';
$client = new OAuth2\Client($CLIENT_ID, $CLIENT_SECRET); if (!isset($_GET['code'])) { $auth_url = $client->getAuthenticationUrl($AUTHORIZATION_ENDPOINT, $REDIRECT_URI); echo(''); } else { $params = array('code' => $_GET['code'], 'redirect_uri' => $REDIRECT_URI); $response = $client->getAccessToken($TOKEN_ENDPOINT, 'my_custom_grant_type', $params); var_dump($response); parse_str($response['result'], $info); $client->setAccessToken($info['access_token']); $response = $client->fetch('https://api.freeagent.com/v2/contacts'); }`
I've also included the example custom grant type inside a file placed after the the IGrantType.php, and included the file, using include(''), inside the main php file, and yet I'm still getting the same issue.