views:

92

answers:

0

Hi folks,

I am trying to get DotNetOpenAuth's DesktopConsumer to work with Google, with not much success actually...

Here is what I am doing (reduced to essential code parts):

myApp = new DesktopConsumer(google, tm); 
var extraParameters = new Dictionary<string, string> {
    { "scope", GetScopeUri(Applications.Calendar) },
};
AuthorizeForm af = new AuthorizeForm(); 
af.setAuthUrl(myApp.RequestUserAuthorization(extraParameters, null, out requestToken));
// This makes a webbrowser control in the AuthorizeForm navigate to the google page 
//which asks for login and authorization
af.ShowDialog(); // Open the form, as modal
var accessTokenResponse =
    myApp.ProcessUserAuthorization(requestToken, af.getVerifier());
// af.getVerifier gets the verificatino code which the user has to copy from the 
// webbrowser control to a textbox (if he grants the authorization, of course :D)
HttpWebRequest req = myApp.PrepareAuthorizedRequest(
    new MessageReceivingEndpoint(
        "http://www.google.com/calendar/feeds/default/owncalendars/full", 
        HttpDeliveryMethods.GetRequest
    ),
    accessTokenResponse.AccessToken);
WebResponse rsp = req.GetResponse();
// Here I get the "401 Unauthorized" exception

Any idea what I am doing wrong?

Thanks in advance, Dmitri