Windows Phone 8 Support

Dec 20, 2012 at 10:05 AM

I have a Windows Phone 8 application. After successfully authenticating/authorization - i save the credentials to isolated storage.

I am able to post to my timeline once, then subsequently i get:

{System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.   at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)   at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)   --- End of inner exception stack trace ---   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)   at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)   at LinqToTwitter.TwitterExecute.<>c__DisplayClass32`1.<ExecuteTwitter>b__2f(IAsyncResult ar)}

Below is my code:

For Authentication (using PinAuthorizer)

private void Complete_Authentication(string pin)
        {
            pinAuth.CompleteAuthorize(
                pin,
                completeResp => Dispatcher.BeginInvoke(() =>
                {
                    switch (completeResp.Status)
                    {
                        case TwitterErrorStatus.Success:
                            var cred = pinAuth.Credentials as IsolatedStorageCredentials;
                            cred.Save();
                            Messenger.Default.Send<bool>(true, "Authentication");
                            NavigationService.GoBack();
                            break;
                        case TwitterErrorStatus.TwitterApiError:
                        case TwitterErrorStatus.RequestProcessingException:
                            MessageBox.Show(
                                completeResp.Error.ToString(),
                                completeResp.Message,
                                MessageBoxButton.OK);
                            Messenger.Default.Send<bool>(false, "Authentication");
                            break;
                    }
                })
            );
        }

 

Afterwards, i make the following call:

auth = new PinAuthorizer
            {
                Credentials = new IsolatedStorageCredentials()
            };
            if (auth == null || !auth.IsAuthorized)
            {
                Console.WriteLine("Failed!!!");
            }
            else
            {
                var twitterCtx = new TwitterContext(auth);
                string status = "Itumo Windows Phone Version. Coming soon...";
                twitterCtx.UpdateStatus(status, true,
                    updateResp => Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        switch (updateResp.Status)
                        {
                            case TwitterErrorStatus.Success:
                                MessageBox.Show(
                                    "Test",
                                    "Update Successfully Posted",
                                    MessageBoxButton.OK);
                                break;
                            case TwitterErrorStatus.TwitterApiError:
                            case TwitterErrorStatus.RequestProcessingException:
                                MessageBox.Show(
                                    updateResp.Error.ToString(),
                                    updateResp.Message,
                                    MessageBoxButton.OK);
                                break;
                        }
                    })
                );
            }

 

I will appreciate any assistance, as this is preventing me from releasing the app to the store.

Coordinator
Dec 20, 2012 at 12:57 PM

Hi,

Can you run Fiddler and let me know the message that Twitter returns? They return a json error message with more details, which can sometimes be helpful.

@JoeMayo

Feb 9, 2013 at 1:56 AM
Was there a resolution to this issue? I am encountering a similar NotFound error during pin authorization.
        public void StartAuthorizing(WebBrowser aOAuthWebBrowser)
        {
            mPinAuth = ShareState.GetPinAuthorizer();
            mPinAuth.UseCompression = true;
            mPinAuth.GoToTwitterAuthorization =
                aPageLink => Dispatcher.BeginInvoke(
                        () => aOAuthWebBrowser.Navigate(new Uri(aPageLink, UriKind.Absolute)));

            mPinAuth.BeginAuthorize(
                aResponse => Dispatcher.BeginInvoke(() =>
                {
                    switch (aResponse.Status)
                    {
                        // Fails with a non-success response here.
                    }
                }));
        }
Feb 9, 2013 at 10:23 AM
Plot thickens. Can't repro the problem on a Nokia 920. Happens on an HTC 8X.
Coordinator
Feb 9, 2013 at 10:45 PM
Please check the version of LINQ to Twitter you're using. Twitter is deprecating their API v1.0 and is in the process of doing intermittent blackouts, which would cause Not Found errors. Any version of LINQ to Twitter including 2.1.x.x and later support Twitter API v1.1. You would want the latest version because it contains more bug fixes.

Joe
Feb 10, 2013 at 12:25 AM
Thanks, Joe. I was running 2.1.2.0 and moved to 2.1.3.0. Same pattern: broken on the 8X, but not on the 920. Tiny detail, the response.Message says, "Check the Error for detail," but in 2.1.3.0, Error has become Exception. The 8X has all latest updates and is on the same Wi-Fi network. Will try Fiddler.
{System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
   at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at LinqToTwitter.OAuthTwitter.<>c__DisplayClass48.<GetRequestTokenAsync>b__47(IAsyncResult ar)}
Coordinator
Feb 10, 2013 at 12:59 AM
Interesting why one device works and the other doesn't. Not sure that I could reproduce that as I only have a Nokia 822 and an emulator. :) I visited dev.twitter.com, looking to see if anyone else is having this problem, but didn't find anything that stuck out. Here's the text from Twitter's description of the 404 Not Found error code:

_404
Not Found The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the requested format is not supported by the requested method.
_

The base URI, in itself, shouldn't have a problem, because that must match the Twitter URL for the endpoint. The request format on all queries is now JSON, which is what all Twitter API endpoints now use. User information sounds like an interesting place to look, so I'll brainstorm some questions that might lead to the next step:
  1. Are you using different user accounts on different phones?
  2. Is the 8x user account valid?
  3. Maybe clear credentials for the user on the 8x and force them to authenticate again.
  4. Do both phones use the same application credentials (ConsumerKey & ConsumerSecret)?
  5. What API are you trying to query?
  6. Does OAuth work for the 8x user? (normally causes a 401, but this covers another base)
  7. If you're querying on behalf of another user, does that user exist (or typos)?
Maybe the answer to some of these will lead us closer to a solution (or identify areas that are not problems).

Joe
Feb 10, 2013 at 6:25 AM
On the 8X, the initial request for the Twitter Pin Authorization page fails, so I do not reach a point where I can enter credentials. I am using the same key/secret on both phones, and I can connect to Twitter in the people hub and the browser on the 8X. After Fiddling around, I found that the error is occurring in the SSL handshake: !SecureClientPipeDirect failed: Authentication failed because the remote party has closed the transport stream. on pipe 479.

Here is the delta for the raw text from the requests, first of the Nokia 920 and second of the 8X. Twitter doesn't issue the 8X a session ticket.

Nokia 920
Random: 51 17 38 F0 C1 B7 DD 83 BF 64 00 27 CA E1 B6 DD 1A 78 55 B1 86 87 22 9A 95 27 D6 A4 37 1D 1E 45
Extensions:
    SessionTicket TLS   33 35 47 E5 FF 82 A3 30 F4 09 2E 04 D4 95 82 AB B2 F9 49 C5 9D A1 55 18 E6 A7 10 9C 75 EE 00 15 B2 2D B3 69 5F A7 0F 88 0C 17 E9 25 B0 31 D1 1C 27 3D 23 D2 1B F0 08 43 E3 8E F6 72 0F AE E3 27 EE C4 32 5A A1 13 50 8F 10 87 4F E4 8B 33 CA AC BE 24 BC 9B 43 78 00 0C AA 33 02 D5 06 76 12 B6 8C 9B 28 86 C5 9B F6 36 36 34 76 B7 03 A3 AC E9 C6 B8 1A 2C B2 75 71 CC 78 CE 52 62 97 42 5F 92 A0 E9 C6 62 11 26 16 78 21 03 FA 45 70 35 F5 80 02 21 DE BB 8C BD 73 7F 78 78 E4 72 B1 C8 A1 23 A9 63 50 3C 27 B3 4E 4E 17 25 C5 D2 1F 06 E9 5A
8X
Random: 50 E5 20 2B E6 94 A3 65 BE 03 8C EE 1C 81 CA 02 A7 A8 DD 3B EB 4B FD 0E 6E 25 27 28 D5 3C 70 E8
Extensions:
    SessionTicket TLS   empty
Coordinator
Feb 10, 2013 at 7:23 PM
I recall some time ago that Twitter updated their SSL certificates. Here's the Blog post:

https://dev.twitter.com/blog/ssl-upgrade-for-twitterapi

I wonder if the 8X needs to update certificates?

Joe