DotNetOpenAuth DesktopConsumer with GData help needed

Posted by DBa on Stack Overflow See other posts from Stack Overflow or by DBa
Published on 2010-04-29T08:11:22Z Indexed on 2010/04/29 8:17 UTC
Read the original article Hit count: 504

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

© Stack Overflow or respective owner

Related posts about dotnetopenauth

Related posts about gdata-api