WinRT Windows 8 OAuth with C#


#1

Hello,

I’m trying to implement a Twitter feed in my app, which should not require logging in or any authentication of the end user/the user of the app. The feed should simply show up in the app, using my API keys and access tokens.

However, I can’t seem to find any librarys which supports WinRT (Windows 8), and I’m unable to authenticate successfully with the following code. Any ideas, people?

    public List<UserTweet.User> jsonFromTwitter;
    private async void fetchTweet()
    {
        var jsonTwitter = new Uri("http://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=test&result_type=recent");

        HttpClient client = new HttpClient();

        var request = new HttpRequestMessage(HttpMethod.Get, jsonTwitter);

        var oAuthHeader = "OAuth oauth_consumer_key=\"XXXXX\", oauth_nonce=\"XXXXX\", oauth_signature=\"XXXXX\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1318622958\", oauth_token=\"XXXXX-XXXXXX\", oauth_version=\"1.0\"";

        request.Headers.Add("Authorization", oAuthHeader);

        var response = await client.SendAsync(request);


        var responseString = await response.Content.ReadAsStringAsync();

        jsonFromTwitter = JsonConvert.DeserializeObject<List<UserTweet.User>>(await client.GetStringAsync(responseString));

        //listbox.ItemsSource = jsonFromTwitter;
    }

#2

I answered this on SO a couple days ago. Here’s the link in case anyone has the same question: http://stackoverflow.com/questions/15175782/oauth-headers-twitter-1-1-c-sharp-fetching-tweets


#3

Hi,
I use LinqToTwitter. Since 3 or 4 Day i get the 401. I changed nothing in my code. I already tried it with the Win8MetroTimeline demo but there comes the same error.

Aby Ideas?


#4

Change http to https in above url and try it out. I encountered same error recently. Changing it to SSL endpoint worked.