I try to get the auth code and use it in the function to access the access token.
but I got this error
InvalidArgumentException: 'queryParams' has bad type; expecting array, got string
getAuthCode:
private function getWebAuth(){
# Include the Dropbox SDK libraries
$appKey = '<REDACTED>';
$appSecret = '<REDACTED>';
$appInfo = new dbx\AppInfo($appKey, $appSecret);
$clientIdentifier = "ExecutiveCoatings";
// Get the current domain protocol to use in the redirect uri
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
// genertate the correct redirect uri
$redirectUri = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$redirectUri = str_replace("dropbox_start","dropbox_finish",$redirectUri);
$csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
$webAuth = new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore);
return $webAuth;
}
I can use the getAuthCode funtion in the dropbox_start method:
public function dropbox_start()
{
$authorizeUrl = $this->getWebAuth()->start();
// send the user to Dropbox authentication page
header('Location: '.$authorizeUrl);
exit();
}
and also in the dropbox_finish method when I set the WebAuth
to WebAuthNoRedirect
and using the generated code statically in the $authCode section but when I want to get $authCode dynamically and set it and other action it gives me the error:
public function dropbox_finish()
{
// get the accessToken from redirected uri
$authCode = $_GET['code'];
list($accessToken, $dropboxUserId) = $this->getWebAuth()->finish($authCode);
var_dump($accessToken);
session_destroy();
die();
}
what is wrong?