I’m looking to set up a test against the Vimeo API and have been using some of the RestSharp tests to set me up. However, since these test were written Vimeo now requirs OAuth2 rather than OAuth1.
I’m having difficulty trying to find resources online advising how I might be able to set up OAuth2 for my test. Based on the below code could someone advise on how I’d need to refactor my code to be able to run the
test successfully(NB-I’m aware that I’m using “OAuth1Authenticator”, which is what was originally there)
public void Can_Query_Vimeo()
{
const string consumerKey = "?????";
const string consumerSecret = "?????";
// arrange
var client = new RestClient
{
BaseUrl = new Uri("http://vimeo.com/api/rest/v2"),
Authenticator = OAuth1Authenticator.ForRequestToken(consumerKey, consumerSecret)
};
var request = new RestRequest();
request.AddParameter("format", "json");
request.AddParameter("method", "vimeo.videos.search");
request.AddParameter("query", "weather");
request.AddParameter("full_response", 1);
// act
var response = client.Execute(request);
// assert
Assert.NotNull(response);
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content);
Assert.False(response.Content.Contains("\"stat\":\"fail\""));
Assert.True(response.Content.Contains("\"stat\":\"ok\""));
}