Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search video with vimeo Api using javascript

I want to use the new vimeo api to fetch videos based on a query, but I getting a 401 Authorization Required with this message "error": "A valid user token must be passed."

I'm using this code :

var urlX = 'https://api.vimeo.com/videos?query=elvis&client_id='+VIMEO_API_KEY;

$.getJSON(urlX, function(data){
console.log(data);
});

So obviously I have an authentication problem. As client_id I'm using my "Client Identifier" from my app created in Vimeo's dashboard. The error I keep getting mention "user token", do I have to generate one via Vimeo's dashboard or via php ? I'm a bit lost here.

like image 301
P33pingtom Avatar asked Jun 05 '26 00:06

P33pingtom


1 Answers

client_id through the querystring is not a valid method of making API calls against the Vimeo API.

First you must request an access token either through the oauth2 redirect worfklow: https://developer.vimeo.com/api/authentication, or by generating it on your app page.

Second you must provide that access token with your api request either through the Authorization header:

Authorization: bearer <your_token>

or the querystring

https://api.vimeo.com/videos?query=elvis&access_token=<your token>.

The authorization header is more secure, and will continue to work indefinitely. Some changes will be made soon to the querystring form which could cause problems with your application.

like image 177
Dashron Avatar answered Jun 06 '26 14:06

Dashron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!