douque9815 2019-05-05 10:35
浏览 51

Dropbox WebAuth() - >完成($ authCode)无效

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作