Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Grant Type not Found #69

Open
danielpointondeveloping opened this issue Jul 11, 2018 · 0 comments
Open

Custom Grant Type not Found #69

danielpointondeveloping opened this issue Jul 11, 2018 · 0 comments

Comments

@danielpointondeveloping

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('<script>window.location="'.$auth_url.'";</script>');
}
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant