duanhan9334 2017-03-10 15:32
浏览 76

在用户身份验证上从Vimeo API获取错误“invalid_client”

I'm attempting to authenticate a user through Vimeo in order to view a list of their videos on the website.

I'm using the Vimeo php library https://github.com/vimeo/vimeo.php with no errors when including it in my code.

I get the authentication URL and am able to navigate to the Allow APP Access page on Vimeo and when I click "Allow" I'm getting the "invalid_client" error on my redirect page, even though they send back a code in the $_GET.

I'm thoroughly confused at this point since I've got the official API library and the APP is set up correctly as far as I can tell. I'm hoping someone might be able to point me in the right direction as to why I'm getting this error and how to fix it!

My Code:

//init Vimeo
require_once("modules/classes/Vimeo/autoload.php");
$lib = new \Vimeo\Vimeo($vimeo_id, $vimeo_secret, $vimeo_access);

if(!isset($_SESSION['vstate'])){
    $_SESSION['vstate'] = base64_encode(openssl_random_pseudo_bytes(30));
}
$vimeo_authurl = $lib->buildAuthorizationEndpoint($redirecturi,'public private',$_SESSION['vstate']);

if(isset($_GET['code'])){

    echo "Code returned: ".$_GET['code'];

    if ($_SESSION['vstate'] != $_GET['state']) {
        echo 'Something is wrong. Vimeo sent back a different state than this script was expecting. Please let an administrator know that this has happened.';
    }

    $tokens = $lib->accessToken($_GET['code'], $redirecturi);
    if ($tokens['status'] == 200) {
        echo 'Vimeo account successfully connected!';
        $_SESSION['access_token'] = $tokens['body']['access_token'];
        $lib->setToken($token['body']['access_token']);
    } else {
        echo 'Sorry, we were unable to connect to your Vimeo account due to the following error:<br/>{'.$tokens['body']['error']."} ".$tokens['body']['error_description'];
    }

    echo "<br/><br/><pre>";
    print_r($tokens);
    echo "</pre>";

    exit();

}

The print_r($tokens) gives this:

Array
(
[body] => Array
    (
        [error] => invalid_client
        [error_description] => A valid client ID must be provided along with any request made to Vimeo's API
    )

[status] => 400
[headers] => Array
    (
        [Server] => nginx
        [Content-Type] => application/json
        [Expires] => Fri, 10 Mar 2017 03:11:17 GMT
        [Cache-Control] => no-store
        [Strict-Transport-Security] => max-age=15552000; includeSubDomains; preload
        [Pragma] => no-cache
        [X-UA-Compatible] => IE=edge
        [X-XSS-Protection] => 1; mode=block
        [X-Content-Type-Options] => nosniff
        [X-Frame-Options] => sameorigin
        [Content-Security-Policy-Report-Only] => default-src https: data: blob: 'unsafe-inline' 'unsafe-eval'; report-uri /_csp
        [Accept-Ranges] => bytes
        [Via] => 1.1 varnish
        [Fastly-Debug-Digest] => 5da2a3ac863afd5f2ad0963779e0dbc4c54c7d97d19f87fd227c5eb8c92bd621
        [Content-Length] => 126
        [Date] => Fri, 10 Mar 2017 15:11:17 GMT
        [Connection] => keep-alive
        [X-Served-By] => cache-iad2146-IAD, cache-ord1731-ORD
        [X-Cache] => MISS, MISS
        [X-Cache-Hits] => 0, 0
        [X-Timer] => S1489158677.346607,VS0,VE55
        [Vary] => Accept,Vimeo-Client-Id,Accept-Encoding,User-Agent
    )
)
  • 写回答

1条回答 默认 最新

  • dongtu1958 2017-03-10 16:37
    关注

    So I'm not exactly sure why, but I created a new APP with the same details and this new APP seemed to authenticate fine.

    The first APP I was having troubles with I had originally sent a request for Upload Access, but was denied (due to local testing links), so perhaps that was the underlying issue with the "invalid_client" error.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。