I'm attempting to have the patreon_user module register accounts with Patreon.
The 'client' on Patreon has the appropriate redirect urls:
https://mysite.com/patreon/oauth and https://mysite.com/patreon_user/oauth
The module throws the error:
Notice: Undefined index: access_token in patreon_get_token()
I added some watchdog code and $tokens is returning:
Array
(
[error] => access_denied
)
I've updated to the latest patreon php library and receive the same error.
I reverted the library, and added a 'scope' variable to get_token in patreon.module:
function patreon_get_token($code, $scope = NULL) {
$return = NULL;
$key = variable_get('patreon_client_id', '');
$secret = variable_get('patreon_client_secret', '');
$library = libraries_load(PATREON_LIBRARY);
if ($library['loaded'] && $key && $secret) {
$oauth_client = new Patreon\OAuth($key, $secret);
$url = patreon_get_callback_url();
if ($scope == 'user') {
$url = patreon_user_get_callback_url();
}
$tokens = $oauth_client->get_tokens($code, $url);
if ($tokens && $access_token = $tokens['access_token']) {
$return = check_plain($access_token);
}
}
return $return;
}
Then in patreon_user.pages.inc line 15, I modified the get_tokens line:
if ($token = patreon_get_token($code, 'user')) {
Comments
Comment #2
mcdoolz commentedComment #4
mrdalesmith commentedThanks for letting me know: I've made a change in the dev version of the module to allow code using the patreon_get_token() function to pass the callback URL. As long as the callback is in patreon_get_allowed_callback_urls() it will be used instead of the default. I'm hoping that will keep the code flexible in case anyone comes up with a different use of the API that needs a separate callback.
Is there any chance you could try the development version and see if it resolves your issue? If so, I'll get a new release sorted.
Comment #5
mcdoolz commentedTested and seems like it works fine.
Comment #6
mrdalesmith commentedNew release released. Cheers for your help.