neuecc / AsyncOAuth

Portable Client Library and HttpClient based OAuth library, including all platform(for PCL).
101 stars 39 forks source link

Yelp API v2 #10

Closed rickduarte closed 10 years ago

rickduarte commented 10 years ago

I'm trying to use the library with Yelp API v2 but I'm only getting a BAD REQUEST as response.

var handler = new OAuthMessageHandler("consumerKey", "consumerSecret", new AccessToken("accessToken", "accessTokenSecret")); var client = new HttpClient(handler); var json = await client.GetAsync("http://api.yelp.com/v2/business/vapiano-ribeirão-preto"); return await json.Content.ReadAsStringAsync();

I found something strange. When I do the request using POSTMAN, the oauth_nouce generated is small than generated from the library:

POSTMAN: oauth_nonce=sZWDGE AsyncOAuth: oauth_nonce="674817390"

Ponf commented 10 years ago

@rickduarte probably you need to UrlEncode your API url first.

rickduarte commented 10 years ago

@Ponf I tried, but still got error. await client.GetAsync(Uri.EscapeUriString("http://api.yelp.com/v2/business/vapiano-ribeirão-preto"));

Yelp uses OAuth 1.0a. Do I need to set any other information?

Ponf commented 10 years ago

@rickduarte I think you need WebUtility.UrlEncode(string) method instead of EscapeUriString