P33pingtom
P33pingtom

Reputation: 63

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.

Upvotes: 3

Views: 3511

Answers (1)

Dashron
Dashron

Reputation: 3998

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.

Upvotes: 3

Related Questions