-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Milestone
Description
Wenn I try to retrieve an OAuth 2 access_token by code everything works fine. But when I try to do the same thing with the refresh_token, it doesn't work out. Here's my code:
$client_id = "blubb";
$client_secret = "bla";
$header = array();
$header[] = "Authorization: Basic ".base64_encode($client_id . ":" .$client_secret);
$header[] = "Accept: application/json";
$payload = array(
'grant_type' => "refresh_token",
'refresh_token' => \UserConfig::get($GLOBALS['user']->id)->OWNCLOUD_REFRESH_TOKEN,
'client_id' => $client_id,
'client_secret' => $client_secret,
'format' => "json",
);
$r = curl_init();
curl_setopt($r, CURLOPT_URL, $owncloud."index.php/apps/oauth2/api/v1/token");
curl_setopt($r, CURLOPT_POST, 1);
curl_setopt($r, CURLOPT_HTTPHEADER, $header);
curl_setopt($r, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($r, CURLOPT_POSTFIELDS, $payload);
$json = curl_exec($r);
curl_close($r);
$json = json_decode($json, true);On the side of my nextcloud he logs the error:
OCA\OAuth2\Exceptions\AccessTokenNotFoundException:
/home/fuhse/nextcloud/apps/oauth2/lib/Controller/OauthApiController.php - line 71: OCA\OAuth2\Db\AccessTokenMapper->getByCode(NULL)
[internal function] OCA\OAuth2\Controller\OauthApiController->getToken(*** sensitive parameters replaced ***)
/home/fuhse/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 160: call_user_func_array(Array, Array)
/home/fuhse/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 90: OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\OAuth2\Controller\OauthApiController), 'getToken')
/home/fuhse/nextcloud/lib/private/AppFramework/App.php - line 114: OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\OAuth2\Controller\OauthApiController), 'getToken')
/home/fuhse/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47: OC\AppFramework\App main('OauthApiControl...', 'getToken', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
[internal function] OC\AppFramework\Routing\RouteActionHandler->__invoke(Array)
/home/fuhse/nextcloud/lib/private/Route/Router.php - line 299: call_user_func(Object(OC\AppFramework\Routing\RouteActionHandler), Array)
/home/fuhse/nextcloud/lib/base.php - line 1000: OC\Route\Router->match('/apps/oauth2/ap...')
/home/fuhse/nextcloud/index.php - line 40: OC handleRequest()
{main}
Does anyone have an idea what t.h. I am missing here? I also couldn't find the string refresh_token in the code of my nextcloud. As far as I have seen, nextcloud should not run into the method OCA\OAuth2\Db\AccessTokenMapper->getByCode(NULL), because I sent 'grant_type' => "refresh_token" in the payload. But it actually does and I have no idea what I could tell him to change that. Of course I alsy tried to set 'code' => "my_refresh_token", but that also did not work.